#GL0000279. Nỗi buồn của Taro khi tính trung bình (The Melancholy of Taro Heikinchi)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nỗi buồn của Taro khi tính trung bình (The Melancholy of Taro Heikinchi)
The Melancholy of Taro Heikinchi
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Taro calculated the average of the integers through by dividing their sum by , but accidentally omitted exactly one integer , where . The erroneous average is . Find all possible pairs sorted by increasing . The input fraction need not be reduced.
Input
One line contains X/Y: integer , a slash /, then integer .
Output
Print each pair N M on its own line in increasing ; if none exists, print exactly Impossible.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Example 1
Input
4/3
Output
3 2
Explanation
For X/Y=4/3, the stated pair gives an omitted sum equal to N times this fraction; other candidate N values fail divisibility or 1<=M<=N.
Example 2
Input
4/6
Output
Impossible
Explanation
For X/Y=4/6, no positive integers N,M satisfy both the average equation and 1<=M<=N.
Example 3
Input
49995/10
Output
10000 10000
Explanation
For X/Y=49995/10, the stated pair gives an omitted sum equal to N times this fraction; other candidate N values fail divisibility or 1<=M<=N.
Example 4
Input
1/400
Output
Impossible
Explanation
For X/Y=1/400, no positive integers N,M satisfy both the average equation and 1<=M<=N.