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 |
my code#include <iostream> using namespace std; int main() { int n; int candy[1000]; int plus[1000]; int minus[1000]; int i; while(cin>>n&&n) { for(i=1;i<=n;i++) cin>>candy[i]; int count=0; while(++count) { for(i=1;i<=n;i++) { minus[i]=candy[i]/2; if(i!=n) plus[i+1]=candy[i]/2; else plus[1]=candy[n]/2; } int z,note=0; for(i=1;i<=n;i++) { candy[i]=candy[i]+plus[i]-minus[i]; if(candy[i]%2) candy[i]++; if(candy[1]!=candy[i]) note++; } if(!note) { cout<<count<<' '<<candy[1]<<endl; break; } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator