标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4942 Accepted Submission(s):
3020
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 int a[1005],n; 6 int xx() 7 { 8 for(int i=1; i<n; i++) 9 { 10 if(a[i]!=a[i-1]) 11 return 1; 12 } 13 return 0; 14 } 15 int main() 16 { 17 int m,i,j,k,w; 18 while(~scanf("%d",&n)&&n) 19 { 20 for(i=0; i<n; i++) 21 scanf("%d",&a[i]); 22 m=0; 23 while(xx()) 24 { 25 m++; 26 w=a[n-1]/2; 27 for(i=n-1; i>0; i--) 28 { 29 a[i]=a[i]/2+a[i-1]/2; 30 if(a[i]%2==1) 31 a[i]++; 32 } 33 a[0]=a[0]/2+w; 34 if(a[0]%2==1) 35 a[0]++; 36 } 37 printf("%d %d\n",m,a[0]); 38 } 39 return 0; 40 }
标签:
原文地址:http://www.cnblogs.com/pshw/p/5259311.html