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

那怎么老wa呢?帮忙看一看了,谢谢!

Posted by 00 at 2005-07-09 21:54:21 on Problem 1666
In Reply To:不记得多大了,反正很小就是了。。。 Posted by:wth at 2005-07-09 21:39:56
#include<iostream.h>
void main()
{
	long N;
	while(1)
	{
		cin>>N;
		if(N==0)
			break;
		long i,j;
		long *c=new long[N],*t=new long[N];
		for(i=0;i<N;i++)
			cin>>c[i];
		for(i=0;;i++)
		{
			for(j=0;j<N;j++)
			{
				if(c[j]%2==1)
					c[j]++;
				c[j]/=2;
				t[j]=c[j];
			}
			for(j=0;j<N;j++)
				c[(j+1)%N]+=t[j];
			for(j=1;j<N;j++)
			{
				if(c[j]!=c[0])
					break;
			}
			if(j==N)
				break;
		}
		cout<<i<<' '<<c[0]<<endl;
		delete [] c,t;
	}
}

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