| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
各位老大 看看我的程序哪错了 我对您的景仰有如滔滔江水连绵不绝,又犹如………………#include <iostream>
using namespace std;
int main()
{
int i,j=0,n,k=0,m=1,x,p[100000],sum=0;
while(cin>>n&&n)
{
for(i=0;i<n;i++)
cin>>p[i];
for(j=0;;j++)
{
for(i=0;i<n;i++)
{
if(p[i]%2!=0)
p[i]=p[i]+1;
}
x=p[0];
for(i=0;i<n-1;i++)
p[i]=p[i]/2+p[i+1]/2;
p[n-1]=(p[n-1]/2)+(x/2);
while(m)
{
if(p[k]==p[k+1])
m=1,k++;
else m=0;
if(k==n-1)
break;
}
m=1;
if(k==n-1)
break;
k=0;
}
cout<<j<<" "<<p[0]<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator