PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000276. Bài toán Euclid (Euclid Problem)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bài toán Euclid (Euclid Problem)
Euclid Problem
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , find integers such that and . Among valid pairs, minimize . If multiple pairs have the minimum, prefer the pair with as specified in the original task.
Input
One line contains two positive integers .
Output
Print three space-separated integers .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
4 6
Output
-1 1 2
Explanation
and . The value is minimum among valid solutions.
Example 2
Input
17 17
Output
0 1 17
Explanation
and . The value is minimum among valid solutions.