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

16ms与0ms的区别,比你少个if()

Posted by sicojuy at 2011-04-23 22:39:33 on Problem 2244
In Reply To:不超时++ Posted by:orangelegend at 2008-09-24 21:45:13
#include <cstdio>

int main()
{
	int n, m, t, r;
	while(scanf("%d", &n), n != 0)
	{
		m = 1;
		while(1)
		{
			r = n - 1;
			t = (m - 1) % r;
			while(t > 0)
			{
				--r;
				t = (t + m - 1) % r;
			}
			if(r == 1)
			{
				printf("%d\n", m);
				break;
			}
			++m;
		}
	}
	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