Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("cmmdc0.in");
- ofstream g("cmmdc0.out");
- int n,p[5]={0,2,3,5,7},nr_exp_aflati=0,ex[5],ed[5],ok[5],sol[5],x,d,produs=1;
- int main()
- {
- f>>n;
- for(int i=1;i<=n;++i)
- {
- f>>x>>d;
- for(int j=1;j<=4;++j)
- if(ok[j]==0)
- {
- ex[j]=0 ;
- while(x%p[j]==0)
- ++ex[j],x/=p[j];
- ed[j]=0;
- while(d%p[j]==0)
- ++ed[j],d=d/p[j];
- if(ex[j]>ed[j])
- ok[j]=1,sol[j]=ed[j],++nr_exp_aflati;
- else
- if(ex[j]>sol[j])
- sol[j]=ex[j];
- }
- if(nr_exp_aflati==4)
- break;
- }
- for(int j=1;j<=4;++j)
- for(int i=1;i<=sol[j];++i)
- produs*=p[j];
- g<<produs;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement