[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;
}
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;
}
留言
張貼留言