2018年1月13日 星期六

UVA Q10038 - Jolly Jumpers

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
int a,b[3000],c[2999],y;
while(cin>>a){
    for(int x=0;x<a;x++){
        cin>>b[x];
    }
    for(int x=0;x<a-1;x++){
        c[x]=abs(b[x+1]-b[x]);
    }
    sort(c,c+(a-1));
    for(y=0;y<a-1;y++){
        if(c[y]!=y+1){
            break;
        }
    }
    if(y==a-1){
        cout<<"Jolly";
    }else{
        cout<<"Not jolly";
    }
    cout<<endl;
}

system("pause");
return 0;
}

沒有留言:

張貼留言