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 |
无语,为使后来的兄弟们少走弯路,给出我的参考。/*author:bjtu1 /*time:8 Apr 2009 #include<stdio.h> #include<memory.h> int gap[3010]; int num[3010]; int main() { int n,dif; int sum,i; while(scanf("%d",&n)!=EOF){ memset(gap,0,sizeof(gap)); sum=0; scanf("%d",&num[0]); for(i=1;i<n;i++){ scanf("%d",&num[i]); dif=(num[i]>num[i-1])?(num[i]-num[i-1]):(num[i-1]-num[i]); if(!gap[dif]&&dif!=0&&dif<=n-1){ sum++; gap[dif]=1; } } if(n==1&&num[0]==1) printf("Jolly\n"); else if(n==1&&num[0]!=1) printf("Not jolly\n"); else if(sum==n-1) printf("Jolly\n"); else printf("Not jolly\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator