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

不超时++

Posted by orangelegend at 2008-09-24 21:45:13 on Problem 2244 and last updated at 2008-09-24 21:45:24
In Reply To:超时和不超时 Posted by:orangelegend at 2008-09-24 21:20:24
#include <stdio.h>
#include <string.h>

int main()
{
	int m,n,i,j;

	while (scanf("%d",&n) != EOF && n != 0)
	{
		m = 1;
		while(1)
		{		
			i = 0;
			j = n - 1;
			while (j != 0)
			{
				i = (i + m - 1) % j;
				j--;
				if (i == 0)
					break;			
			}
			if (j == 0)
			{
				printf("%d\n",m);
				break;
			}
			m++;
		}	
	}

	return 0;
}

16ms

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