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 |
没那么麻烦吧,看看我的代码#include<iostream> #include<cmath> #include<algorithm> using namespace std; int main() { int record[3005]; int absolute[3005]; int n; while(cin>>n) { cin>>record[0]; for(int i=1;i<n;i++) { cin>>record[i]; absolute[i-1]=abs(record[i]-record[i-1]); } sort(absolute,absolute+n-1); // cout<<"absolute[n-2]"<<absolute[n-2]<<" n-1 is "<<n-1<<endl; int flag=0; for(int j=0;j<=n-2;j++) { if(absolute[j]!=j+1) { cout<<"Not jolly"<<endl; flag=1; break; } } if(flag==0) cout<<"Jolly"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator