PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000107. Cặp số có ƯCLN cho trước (Problem about GCD)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cặp số có ƯCLN cho trước (Problem about GCD)
Problem about GCD
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given , find integers satisfying and , maximizing . Break ties by choosing the smallest . Print -1 -1 if no such pair exists. The equality is allowed.
Input
One line containing .
Output
Print the optimal pair , or -1 -1 if no pair exists.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Input
4 8 2
Output
4 6
Explanation
The multiples of in the interval are . The pair has GCD and is invalid. The pair has GCD and the maximum possible distance .