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

菜鸟问:类似的方法为啥别人的ac了我的超时了。

Posted by mjh9001 at 2012-05-26 14:01:27 on Problem 1012
别人通过的代码http://poj.org/showmessage?message_id=96082

下边是我的
#include <iostream>
using namespace std;
int main()
{
	int n;
	int i=0;
	int re[100];
	cin>>n;
	while(n!=0)
	{
		int m,now,sym;
		m=n;
		while(1)
		{
			m++;
			now=n+n;
			sym=0;
			while (1)
			{
				sym=(sym+m-1)%now+1;
				if (sym<=n)
					break;
				else
				{
					now--;
					sym--;
				}
			}
			if (now==n)
			{
				re[i]=m;
				break;
			}
		}
		i++;
		cin>>n;
	}
	for (int j=0;j<i;j++)
		cout<<re[j]<<endl;
	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