Advertisement
a53

Factori1

a53
Jan 30th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 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,sumx1=0,y1=x1,y2=x2;
  9. while(x1>1)
  10. {
  11. if(x1%d==0)
  12. {
  13. sumx1+=d;
  14. while(x1%d==0)
  15. x1/=d;
  16. }
  17. ++d;
  18. if(d*d>x1)
  19. sumx1+=x1,x1=1;
  20. }
  21. int sumx2=0;
  22. d=2;
  23. while(x2>1)
  24. {
  25. if(x2%d==0)
  26. {
  27. sumx2+=d;
  28. while(x2%d==0)
  29. x2/=d;
  30. }
  31. ++d;
  32. if(d*d>x2)
  33. sumx2+=x2,x2=1;
  34. }
  35. if(sumx1==sumx2)
  36. cout<<min(y1,y2);
  37. else
  38. {
  39. if(sumx1>sumx2)
  40. cout<<y1;
  41. else
  42. cout<<y2;
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement