您的位置:首页 > 其它

zoj 1879 Jolly Jumpers

2012-03-31 12:32 239 查看
#include "iostream"
#include "memory.h"
#include "cmath"
using namespace std;
int num[3010], ans[3010];
int main()
{
int n, i;
bool tag;
while (cin >> n)
{
tag = false;
if (n == 1)
{
for (i = 1; i <= n; i++)
cin >> num[i];
cout << "Jolly" << endl;
}
else
{
memset(num, 0, sizeof(num));
memset(ans, 0, sizeof(ans));
for (i = 1; i <= n; i++)
cin >> num[i];
for (i = 1; i < n; i++)
{
int temp = abs (double(num[i+1] - num[i]));
if (temp < 1 || temp > n)
{
tag = true;
break;
}
ans[temp] = 1;
}
for (i = 1; i < n; i++)
{
if (ans[i] != 1)
{
tag = true;
break;
}
}
if (!tag)
cout << "Jolly" << endl;
else
cout << "Not jolly" << endl;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: