现在的位置: 首页 > 综合 > 正文

ZOJ 1879

2012年12月16日 ⁄ 综合 ⁄ 共 591字 ⁄ 字号 评论关闭

///////////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
using namespace std;
bool st[3000];

 

int main()
{
    int n;
    int a,b;
    while(cin>>n)
    {
        cin>>a;
        int i;
        int temp;
        for(i=0;i<3000;i++)
            st[i]=0;
        for(i=1;i<n;i++)
        {
            cin>>b;
            temp=abs(a-b);
            if(temp<1 || temp>n-1)
                continue;
            st[temp]=1;
            a=b;
        }
        int flag=1;
        for(i=1;i<=n-1;i++)
            if(!st[i])
                flag=0;
        if(flag)
            cout<<"Jolly"<<endl;
        else
            cout<<"Not jolly"<<endl;
    }
    return 0;
}

 

抱歉!评论已关闭.