HDU 1034 各种水,各种暴力都能过
/*
* Author:lonelycatcher
* peoblem:hdu 1034
* Type:模拟暴力各种暴力都能过
*/
#include<string.h>
#include<stdio.h>
#include<iostream>
using namespace std;
int OK,N;
int candy[100000];
int main()
{
setbuf(stdout,NULL);
int i,steps;
while(scanf("%d",&N)!=EOF)
{
steps=0;
if(!N)break;
for(i=1;i<=N;i++)
{
scanf("%d",&candy[i]);
}
while(true)
{
steps++;
OK=1;
int temp=candy[N];
candy[N]=(candy[N]>>1);
for(i=N;i>=2;i--)
{
candy[i]+=(candy[i-1]>>1);
if(candy[i]&1)candy[i]++;
candy[i-1]/=2;
}
candy[1]+=(temp>>1);
if(candy[1]&1)candy[1]++;
for(i=1;i<=N-1;i++)
{
if(candy[i]!=candy[i+1])
{
OK=0;
break;
}
}
if(OK==1)break;
}
printf("%d %d\n",steps,candy[1]);
}
return 0;
}
posted on 2011-08-01 08:16 lonelycatcher 阅读(439) 评论(0) 编辑 收藏 举报