Advertisement
a53

Factori2

a53
Jan 30th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int x1,x2;
  7. cin>>x1>>x2;
  8. int d=2,prodx1=1,y1=x1,y2=x2;
  9. while(x1>1)
  10. {
  11. if(x1%d==0)
  12. {
  13. prodx1*=d;
  14. while(x1%d==0)
  15. x1/=d;
  16. }
  17. ++d;
  18. if(d*d>x1)
  19. prodx1*=x1,x1=1;
  20. }
  21. int prodx2=1;
  22. d=2;
  23. while(x2>1)
  24. {
  25. if(x2%d==0)
  26. {
  27. prodx2*=d;
  28. while(x2%d==0)
  29. x2/=d;
  30. }
  31. ++d;
  32. if(d*d>x2)
  33. prodx2*=x2,x2=1;
  34. }
  35. if(prodx1==prodx2)
  36. cout<<min(y1,y2);
  37. else
  38. {
  39. if(prodx1>prodx2)
  40. cout<<y1;
  41. else
  42. cout<<y2;
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement