PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000289. Xóa bảng và khôi phục hai số (Wipe Your Whiteboards)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Xóa bảng và khôi phục hai số (Wipe Your Whiteboards)
Wipe Your Whiteboards
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A whiteboard shows an incomplete calculation from the extended Euclidean algorithm. Its two original positive integer inputs and have been erased. Three remaining integers are known to satisfy
Find positive integers satisfying the equality. Among all such pairs, minimize ; then minimize if necessary. The input guarantees a positive integer solution exists.
Input
One line containing three integers in that order.
Output
Print two positive integers , the required optimal pair, separated by one space.
Subtasks
- Subtask 1 (20 points): ; ; ; is divisible by .
- Subtask 2 (30 points): ; ; ; is divisible by .
- Subtask 3 (50 points): ; ; ; is divisible by .
Examples
Input
3 -5 15
Output
10 3
Explanation
For , we get . No smaller positive value of can yield a positive integer satisfying the equation, so the pair is optimal.