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

Re:改了一下。。。。结果还是。。。。。超时 貌似时间稍微短点

Posted by vince4053040 at 2009-12-22 18:22:39 on Problem 1012
In Reply To:Re:做了这么久。。。。。超时 Posted by:vince4053040 at 2009-12-22 13:16:16
#include<iostream>
using namespace std;
int main()
{
	int n,m,v,ssss,w;
	bool a[3002];
	int i,nCount;
	int pp,j;
	while(cin>>w)
	{
		n=2*w;
		pp=n;
		if(!n) break;
		for(m=w;;m++)
		{
			ssss=0;
			j=0;
			v=1;
			n=2*w;
			for(i=0;i<n;i++)
				a[i]=true;
			while(n>1)
			{
				nCount=0;
				while(nCount<m)
				{
					j=j%pp;   //形成一个圆圈
					if(a[j]==true)
						nCount++;
					j++;
				}
				a[j-1]=false;
				//cout<<j<<" ";//输出每次剔除的个数
				if(j<=w)
					break;
				v++;
				n--;
			}
			if(v>w)
			{
				cout<<m<<endl;
				break;
			}		
		}
	}
	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