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 |
用set还是很方便的。给大家参考下#include <iostream> #include <cmath> #include <algorithm> #include <set> using namespace std; int main() { int index[3001]={0}; int total_num; while(scanf("%d",&total_num)==1) { int temp; set<int>result; for (int i = 0 ;i<total_num;++i) { scanf("%d",&temp); index[i]=temp; if (i!=0) { temp=(index[i]-index[i-1])>0?(index[i]-index[i-1]):(index[i-1]-index[i]); if(temp>0&&temp<total_num) result.insert(temp); } } if(result.size()==total_num-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