Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int a,b,wyn1,wyn2,w;
- cin>>a>>b;
- for(int i=2;i<=1000;i++)
- {
- a/=__gcd(a,i);
- if(a==1)
- {
- wyn1=i;
- break;
- }
- }
- if(a!=1)wyn1=a;
- for(int i=2;i<=1000;i++)
- {
- b/=__gcd(b,i);
- if(b==1)
- {
- wyn2=i;
- break;
- }
- }
- if(b!=1)wyn2=b;
- if(wyn1<wyn2)cout<<wyn1<<"\n";
- else cout<<-1<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement