fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define pb push_back
  4. using namespace std;
  5. void solve()
  6. {
  7. int a,b;
  8. cin>>a>>b;
  9. int nod=__gcd(a,b);
  10. a/=nod;
  11. b/=nod;
  12. int x=a,y=b;
  13. for (int i=2;i*i<=a;i++)
  14. {
  15. while (x%(i*i)==0)
  16. {
  17. x/=(i*i);
  18. }
  19. }
  20. for (int i=2;i*i<=b;i++)
  21. {
  22. while (y%(i*i)==0)
  23. {
  24. y/=(i*i);
  25. }
  26. }
  27. cout<<x<<" "<<y<<"\n";
  28. }
  29. signed main()
  30. {
  31. int t;
  32. cin>>t;
  33. while(t--)
  34. {
  35. solve();
  36. }
  37. return 0;
  38. }
  39. //292155853 252471085 - ответ жюри
Success #stdin #stdout 0s 15224KB
stdin
1
531192460 555436387
stdout
132798115 555436387