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 qjklw at 2010-01-30 11:49:36 on Problem 1012 and last updated at 2010-01-30 11:52:15
In Reply To:Re:改了一下。。。。结果还是。。。。。超时 貌似时间稍微短点 Posted by:vince4053040 at 2009-12-22 18:22:39
> #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