fork download
  1. def frac(f):
  2. a,b = f
  3. while b:
  4. a, b = b, a%b
  5. return (f[0]//(a or 1), f[1]//(a or 1))
  6.  
  7.  
  8. # # # test # # #
  9. t = """4 8
  10. 1536 78360
  11. 51478 5536
  12. 46410 119340
  13. 7673 4729
  14. 4096 1024"""
  15. for line in t.splitlines():
  16. ans = frac(tuple(map(int, line.split())))
  17. print(' '.join(map(str, ans)))
Success #stdin #stdout 0.02s 9944KB
stdin
Standard input is empty
stdout
1 2
64 3265
25739 2768
7 18
7673 4729
4 1