| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
牛人们帮忙看一下,为什么WA啊???谢谢了!!!#include<stdio.h>
#include<math.h>
void main()
{
int a[3000],n,i,j,b[3000],t,flag=1;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(i!=0)
b[i-1]=abs(a[i]-a[i-1]);
}
for(i=0;i<n-1;i++)
for(j=0;j<n-2-i;j++)
if(b[j]>b[j+1])
{t=b[j];b[j]=b[j+1];b[j+1]=t;}
for(i=1;i<n-1;i++)
{
if(b[0]==1&&b[i]-b[i-1]==1&&b[n-2]==n-1)
flag=1;
if(b[0]!=1||b[i]-b[i-1]!=1||b[n-2]!=n-1)
flag=0;
}
if(flag==1)
printf("Jolly\n");
else
printf("Not jolly\n");
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator