daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Jan 16th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     ios_base::sync_with_stdio(0);
  6.     cin.tie(0);
  7.     cout.tie(0);
  8.     int a,b,wyn1,wyn2,w;
  9.     cin>>a>>b;
  10.     for(int i=2;i<=1000;i++)
  11.     {
  12.         a/=__gcd(a,i);
  13.         if(a==1)
  14.         {
  15.             wyn1=i;
  16.             break;
  17.         }
  18.     }
  19.     if(a!=1)wyn1=a;
  20.     for(int i=2;i<=1000;i++)
  21.     {
  22.         b/=__gcd(b,i);
  23.         if(b==1)
  24.         {
  25.             wyn2=i;
  26.             break;
  27.         }
  28.     }
  29.     if(b!=1)wyn2=b;
  30.     if(wyn1<wyn2)cout<<wyn1<<"\n";
  31.     else cout<<-1<<"\n";
  32. }
RAW Paste Data
Top