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,prodx1=1,y1=x1,y2=x2;
- while(x1>1)
- {
- if(x1%d==0)
- {
- prodx1*=d;
- while(x1%d==0)
- x1/=d;
- }
- ++d;
- if(d*d>x1)
- prodx1*=x1,x1=1;
- }
- int prodx2=1;
- d=2;
- while(x2>1)
- {
- if(x2%d==0)
- {
- prodx2*=d;
- while(x2%d==0)
- x2/=d;
- }
- ++d;
- if(d*d>x2)
- prodx2*=x2,x2=1;
- }
- if(prodx1==prodx2)
- cout<<min(y1,y2);
- else
- {
- if(prodx1>prodx2)
- cout<<y1;
- else
- cout<<y2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement