您的位置:首页 > 其它

UVa 10038 Jolly Jumpers

2010-02-22 13:03 344 查看
/*
coder: ACboy
date: 2010-2-22
result: AC
description:
*/

#include <iostream>
using namespace std;
#define MAXN 3000 + 10

int flag[MAXN];
int data[MAXN];

int main()
{
int i, j;
int n;

#ifndef ONLINE_JUDGE
freopen("10038.txt", "r", stdin);
#endif

while (cin >> n)
{
for (i = 0; i < n; i++)
{
cin >> data[i];
}

memset(flag, 0, sizeof(flag));
int ans = 1;
for (i = 0; i < n - 1; i++)
{
if (abs(data[i + 1] - data[i]) > n - 1) { ans = 0; break;}
if (flag[abs(data[i + 1] - data[i])] == 0) flag[abs(data[i + 1] - data[i])] = 1;
else
{
ans = 0;
break;
}
}
if (ans) cout << "Jolly" << endl;
else cout << "Not jolly" << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  2010