题目:http://acm.hdu.edu.cn/showproblem.php?pid=1034
这真又是一道水题。我开始还觉得模拟会不会超时,想找规律,弄了半天没弄出来。然后就直接放OJ试试看。然后AC了???鬼鬼。
#include<bits/stdc++.h>
#define PI 3.1415926
#define INF 1e18
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX = 1e3+50;
int a[MAX],b[MAX];
int n;
bool check(){
for(int i = 1 ; i <= n-1 ; i++)
if(a[i]!=a[i+1])
return false;
return true;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while(cin>>n){
if(!n) break;
ll ans = 0;
for(int i = 1 ; i <= n ; i++)
cin>>a[i];
while(!check()){
ans++;
for(int i = 1 ; i <= n ; i++){
int next = i+1 ;
if(next > n) next = 1;
a[i] = a[i]/2;
b[next] = a[i];
}
for(int i = 1 ; i <= n ; i++){
a[i] += b[i];
if(a[i]%2==1) a[i]++;
}
/* for(int i = 1 ; i <= n ; i++)
cout<<a[i]<<" ";
cout<<endl;
*/
}
cout<<ans<<" "<<a[1]<<endl;
}
return 0;
}