Jerry and Tom
InterviewTime limit1sMemory limit128 MB
Subtract the fraction A/B from 1 and print the remaining cheese as P/Q in lowest terms.
- Level
Easy1 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
Tom bought 1 kg of cheese at the store and came back home.
While Tom was looking away, Jerry came and stole A/B kg of it.
How much cheese does Tom have left after Jerry stole some?
Input
The first line gives two integers A and B (1 ≤ A < B ≤ 9).
A and B are guaranteed to be coprime.
Output
If the answer, written as a fraction in lowest terms, is P/Q kg, print P and Q on the first line separated by a space.