#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("bac.in");
int main()
{
int n,F[1001]={0},a=-1,r=0,ok=1;
while(fin>>n)
F[n]=1; //vector caracteristic
for(int i=0;i<=1000;i++)
if(F[i]==1)//element care apare
{
if(r==0)
{ //calculez ratia din primele 2
if(a!=-1) r=i-a;
}
else if(i-a!=r) ok=0; //verific daca ratia se pastreza
a=i; //retin elementul anterior
}
if(ok) cout<<r;
else cout<<"NU";
}
|