409139: GYM103446 D Strange Fractions
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
D. Strange Fractionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Given a positive fraction $$$\frac{p}{q}$$$, you should find two positive integers $$$a,b$$$ that $$$\frac{p}{q} = \frac{a}{b} + \frac{b}{a}$$$. If no such integers, report it.
InputThe first line contains one integer $$$T\,(1\le T \le 10^5)$$$, denoting the number of test cases.
For each test case:
Input one line containing two integers $$$p,q\,(1\le p,q \le 10^7)$$$, denoting the given fraction.
OutputFor each test case:
If solution exists, output one line containing two integers $$$a,b\,(1\le a,b \le 10^9)$$$, or print two zeros in one line if no solution.
ExampleInput2 5 2 5 1Output
1 2 0 0Note
For the first case, $$$\frac{5}{2} = \frac{1}{2} + \frac{2}{1}$$$ holds. So one possible solution is $$$a=1,b=2$$$.