[ZJd097][UVA10038] Jolly Jumpers

題目:
http://zerojudge.tw/ShowProblem?problemid=d097
-----------------------------------------------------------------------------------------------------------------------

#include<cstdio>
#define maxn 3000+1
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int a[maxn] = {0}, y = 0, x = 0, ans = 0, z = 0;
scanf("%d",&x);
for(int i=1;i<n;i++)
{
scanf("%d",&y);
ans = x-y>=0?x-y:y-x;
a[ans] = 1;
x = y;
}
for(int i=1;i<=n-1;i++)
{
if(!a[i])
{
z = 1;
break;
}
}
printf("%s\n",!z ? "Jolly" :"Not jolly");
}
return 0;
}

留言

這個網誌中的熱門文章

[ZJ]a227: 三龍杯 -> 河內之塔

建立 python 環境(windows 8)

[ZJ]b513: 判斷質數-商競103