Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int A[2501];
- int cmmdc(int a, int b)
- {
- if(b==0) return a;
- else return cmmdc(b,a%b);
- }
- int main()
- {
- int n;
- cin>>n;
- for(int i=1;i<=n;i++) cin>>A[i];
- for(int i=1;i<n;i++)
- for(int j=i+1;j<=n;j++)
- if(A[i]>A[j])
- {
- int aux=A[i];
- A[i]=A[j];
- A[j]=aux;
- }
- int r=0;
- for(int i=1;i<n;i++)
- r=cmmdc(r,A[i+1]-A[i]);
- bool p=true;
- if(r<2) p=0;
- else for(int i=2;i<=n;i++)
- if(A[i]%r!=A[1]%r) p=0;
- if(p==true) cout<<"DA";
- else cout<<"NU";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement