Advertisement
Guest User

VerifProgresie

a guest
Dec 12th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int A[2501];
  6.  
  7. int cmmdc(int a, int b)
  8. {
  9.     if(b==0) return a;
  10.     else return cmmdc(b,a%b);
  11. }
  12.  
  13. int main()
  14. {
  15.     int n;
  16.     cin>>n;
  17.     for(int i=1;i<=n;i++) cin>>A[i];
  18.     for(int i=1;i<n;i++)
  19.         for(int j=i+1;j<=n;j++)
  20.             if(A[i]>A[j])
  21.             {
  22.                 int aux=A[i];
  23.                 A[i]=A[j];
  24.                 A[j]=aux;
  25.             }
  26.     int r=0;
  27.     for(int i=1;i<n;i++)
  28.         r=cmmdc(r,A[i+1]-A[i]);
  29.     bool p=true;
  30.     if(r<2) p=0;
  31.     else for(int i=2;i<=n;i++)
  32.             if(A[i]%r!=A[1]%r) p=0;
  33.     if(p==true) cout<<"DA";
  34.     else cout<<"NU";
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement