标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
1 #include <cstdio> 2 #include <cmath> 3 #include <cstring> 4 #include <ctime> 5 #include <iostream> 6 #include <algorithm> 7 #include <set> 8 #include <vector> 9 #include <sstream> 10 #include <queue> 11 #include <typeinfo> 12 #include <fstream> 13 #include <map> 14 #include <stack> 15 using namespace std; 16 #define INF 100000 17 typedef long long ll; 18 const int maxn=10010; 19 int a[maxn],tmp[maxn]; 20 int main() 21 { 22 int n; 23 while(scanf("%d",&n)==1){ 24 if(n==0) break; 25 for(int i=1;i<=n;i++) 26 scanf("%d",&a[i]); 27 int same,ans=0,num; 28 while(1){ 29 same=1; 30 for(int i=1;i<=n;i++) 31 if(a[i]%2!=0) a[i]++; 32 for(int i=2;i<=n;i++) 33 if(a[i]==a[i-1]) {num=a[i];same++;} 34 else break; 35 if(same==n) break; 36 for(int i=1;i<=n;i++){ 37 a[i]=a[i]/2; 38 tmp[i]=a[i]; 39 } 40 for(int i=1;i<=n;i++){ 41 if(i==1) a[i]+=tmp[n]; 42 else a[i]+=tmp[i-1]; 43 } 44 ans++; 45 } 46 printf("%d %d\n",ans,num); 47 } 48 return 0; 49 }
标签:
原文地址:http://www.cnblogs.com/RRirring/p/4729486.html