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 13:16:16 on Problem 1012
In Reply To:做了这么久。。。。。超时 Posted by:vince4053040 at 2009-12-22 13:11:53
#include<iostream>
using namespace std;
int main()
{
	int n,m,v,ssss,w;
	bool a[3002];
	int b[16];
	int i,nCount;
	int pp,j;
	while(cin>>w)
	{
		n=2*w;
		pp=n;
		if(!n) break;
		for(m=w;;m++)
		{
			ssss=0;
			memset(b,0,sizeof(b));
			j=0;
			v=0;
			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;
				b[v]=j;//输出每次剔除的个数
				//j++;         //上面已经加了1 这不能再加
				v++;
				n--;
			}
			for(v=0;v<w;v++)
			{
				if(b[v]<=w)
					ssss=1;
			}
			if(ssss==0)
			{
				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