#include<iostream> using namespace std; int main() { int num_stu; int i; int time=0; do{ time=0; cin>>num_stu; if(num_stu==0) break; int * counts=new int[num_stu]; int * count=new int[num_stu]; for(i=0;i<num_stu;i++){ cin>>counts[i]; count[i]=counts[i]; } while(++time) { for(i=0;i<num_stu-1;i++) { count[i+1]=counts[i]/2+counts[i+1]/2; if(count[i+1]%2!=0) count[i+1]++; } count[0]=counts[num_stu-1]/2+counts[0]/2; if(count[0]%2!=0) count[0]++; for(i=0;i<num_stu;i++) counts[i]=count[i]; for(i=0;i<num_stu-1;i++) if(counts[i]!=counts[i+1]) break; if(i==num_stu-1) break; } cout<<time<<" "<<counts[0]<<endl; delete []counts; delete []count; }while(1); }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com