ENIGMATH - PLAY WITH MATH
You would have been fed up with competitive programming questions so far, now it is time to solve little math.
Assume you have a equation A * x - B * y = 0
For a given value of A and B, find the minimum positive integer value of x and y that satisfies this equation.
First line contains T, number of test cases 0 <= T <=1000 followed by T lines.
First line of each test case contains two space seperated integers A and B. 1 <= A, B <=1 000 000 000.
For each test case, output a single line containing two integers x and y (seperated by a single space).
Input: 1 2 3 Output: 3 2
- Brute force won't pass the given constraint.
- Negative number cases are avoided to make the problem easy.
Last edit: 2019-01-19 20:21:37
Took me 2 WA finally ;)
Cari KPK nya habistu , a sama b nya di bagi sama KPK nya
its my 50th
just find the lcm then divide lcm by a and b...x and y will be respective values....AC in one go...
AC in one Go...!!
dont read comments....
just solve eq for x and y.
Print minimum values of (x,y) not value of x&y, and not minimum value of x followed by matching y. Print each result on a separate line, don't insert additional newlines like comments suggest. Crap statement and crap judge: if a < b print the bigger value first else WA. WTF!
Easiest question... Don't forget to print new line. Costed me one WA