#P2406. 最小和

最小和

Description

Given that a,ba, b are positive integers with aba \leq b.

Find x,yx, y that satisfy the conditions and minimize x+yx + y.

Conditions:

  • gcd(x,y)=a\gcd(x, y) = a;
  • lcm(x,y)=b\mathrm{lcm}(x, y) = b;
  • xyx \leq y.

Input Format

Multiple test cases, terminated by EOF.

There are at most 10310^3 lines, each containing two numbers a,ba, b.

Output Format

Output the same number of lines as in the input. For each line, output two numbers x,yx, y, separated by a single space.

3 60
12 15
200 20000
300 30000
400 40000
800 5000
1200 7500
1600 10000

Hint

3a,b<2633 \leq a, b < 2^{63}.

Terminated by EOF; there is no line count nn, and the first line is testdata.

The testdata are randomly generated.

Translated by ChatGPT 5