纯模拟,读懂题就能做,注意下hit就行了
#include <stdio.h>
int n;
int num[2000], t[2000];
int init()
{
int i;
for ( i = 0 ; i < n; i++ )
if ( num[i]%2 )
num[i]+=1;
for ( i = 1; i < n ; i++)
if ( num[0] != num[i] )
return 1;
return 0;
}
int main()
{
while ( EOF != scanf("%d", &n) && n )
{
int i, m = 0;
for ( i = 0; i < n ; i++ )
scanf("%d", num+i);
while (init())
{
m++;
for ( i = 0; i < n; i++ )
{
num[i]>>=1;
t[(i+1)%n]=num[i];
}
for ( i = 0 ; i < n ; i++ )
num[i]+=t[i];
}
printf("%d %d\n", m, num[0]);
}
return 0;
}