Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int x1,x2;
- cin>>x1>>x2;
- int d=2,sumx1=0,y1=x1,y2=x2;
- while(x1>1)
- {
- if(x1%d==0)
- {
- sumx1+=d;
- while(x1%d==0)
- x1/=d;
- }
- ++d;
- if(d*d>x1)
- sumx1+=x1,x1=1;
- }
- int sumx2=0;
- d=2;
- while(x2>1)
- {
- if(x2%d==0)
- {
- sumx2+=d;
- while(x2%d==0)
- x2/=d;
- }
- ++d;
- if(d*d>x2)
- sumx2+=x2,x2=1;
- }
- if(sumx1==sumx2)
- cout<<min(y1,y2);
- else
- {
- if(sumx1>sumx2)
- cout<<y1;
- else
- cout<<y2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement