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 |
纪念我的100题。#include <iostream> #include <cstdio> using namespace std; int n[10000]; void pass(int num) { int *newn=new int[num]; for(int i=0;i<num;i++) { newn[(i+1)%num]=n[(i+1)%num]/2+n[i]/2; if(newn[(i+1)%num]%2==1) (newn[(i+1)%num])++; } for(int j=0;j<num;j++) n[j]=newn[j]; } bool judge(int num) { for(int i=1;i<num;i++) if(n[i]!=n[0]) return false; return true; } void main() { int num; while(cin>>num && num!=0) { for(int i=0;i<num;i++) cin>>n[i]; int count=0; while(1) { pass(num); if(judge(num)) { count++; break; } else count++; } cout<<count<<" "<<n[0]<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator