Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

到底哪里有错(有代码)

Posted by neverend at 2007-06-22 18:54:43 on Problem 1666
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator