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 ectt at 2005-07-04 16:53:46 on Problem 1012
In Reply To:不用链表更快 Posted by:tengshengbo at 2004-09-05 01:14:03
> #include<iostream.h>
> bool check(int i,int j)
> {
> 	int start=1;
> 	int x;
> 	int leng=2*i;
> 	for(x=1;x<=i;x++)
> 	{
> 		start=(start+j-1)%leng;
> 		if(start==0) start=leng;
> 		leng--;
> 		if(start<=i) return false;
> 		if(start>leng) start=1;
> 	}
> 	return true;
> }
> main()
> {
>     int a[15];
> 	int i,j;
> 	for(i=1;i<14;i++)
> 	{
> 		for(j=i+1;;j++)
> 		{
> 			if(check(i,j))
> 			{
> 				a[i]=j;
> 				break;
> 			}
> 		}
> 	}
> 	cin>>i;
> 	while(i!=0)
> 	{
> 		cout<<a[i]<<endl;
> 		cin>>i;
> 	}
> }

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