标签:acm
#include <bits/stdc++.h> using namespace std; #define maxn 105 int a[maxn]; int b[maxn]; int n; int ans; void solve() { while(1) { for(int i=1; i<=n; i++) { b[i] = a[i]/2; a[i] /= 2; } for(int i=1; i<=n; i++) { if(i == 1) a[i] += b[n]; else a[i] += b[i-1]; } for(int i=1; i<=n; i++) { if(a[i] & 1) { a[i]++; ans++; } } int flag = true; for(int i=1; i<n; i++) { if(a[i] != a[i+1]) { flag = false; break; } } if(flag) break; } } int main() { while(cin>>n) { ans = 0; for(int i=1; i<=n; i++) cin>>a[i]; solve(); cout<<ans<<endl; } return 0; }
标签:acm
原文地址:http://blog.csdn.net/dojintian/article/details/44921435