| ||||||||||
| 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"
#include"iomanip"
using namespace std;
int main()
{
int N,i,j,k,count,flag;
int *a,*b;
while(1)
{
flag=1;
scanf("%d",&N);
if(N)
{a=(int *)malloc(N*sizeof(int));
b=(int *)malloc(N*sizeof(int));}
else
break;
for(i=0;i<N;i++)
scanf("%d",&a[i]);
count=0;
while(flag)
{
for(k=0;k<N;k++)
b[k]=a[k]/2;
for(j=0;j<N;j++)
a[j%N]=b[j%N]+b[(j-1+N)%N];
i=0;count++;
while(a[i]==a[i+1])
{
i++;
if(i>=N)
break;
}
if(i>=N)
{
flag=0;
printf("%d %d",count,a[0]);
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator