Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- #include <cmath>
- using namespace std;
- int cmmdc (int a, int b)
- {
- int r,d,i;
- d=a;
- i=b;
- while (i>0)
- {
- r=d%i;
- d=i;
- i=r;
- }
- return d;
- }
- /**int nrdiv (int x)
- {
- {
- int nrd=1;
- int p=0,d=2;
- while (x%d==0)
- {
- p++;
- x/=d;
- }
- if (p>0)
- {
- nrd*=(p+1);
- }
- d=3;
- while (x>1)
- {
- p=0;
- while (x%d==0)
- {
- x/=d;
- p++;
- }
- if (p)
- {
- nrd*=(p+1);
- }
- if (d*d<x)
- {
- d=d+2;
- }
- else
- {
- d=x;
- }
- }
- return nrd;
- }
- }*/
- int main ()
- {
- int n,i,a,b,r,c;
- int minim=INT_MAX;
- int maxim=INT_MIN;
- cin>>n;
- for (i=1; i<=n; i++)
- {
- cin>>a>>b;
- c=cmmdc(a,b);
- r=sqrt(c);
- if (c<minim && r*r!=c)
- {
- minim=c;
- }
- if (c>maxim && r*r==c)
- {
- maxim=c;
- }
- }
- if (minim==INT_MAX || maxim==INT_MIN)
- {
- cout<<"NU EXISTA";
- return 0;
- }
- cout<<minim<<" "<<maxim;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement