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 wuyifan00 at 2011-09-16 17:34:01 on Problem 1012
In Reply To:Re:总结三点 Posted by:tanguofu at 2009-12-13 21:55:22
还是超时啊...
真是很崩溃啊..
我自己统计时间才280MS啊..这怎么回事哇?
int josephRing( int k ){
	int m = 1;
	int index = 0;
	int ringSize = 2 * k;
	int pos = 0;
	int count = 0;
	while(1){
		count = m * (k + 1);
		for( index = 0; index <= 1; index++ ){
			count = count + index;
			ringSize = 2 * k;
			pos = 0;
			while( 1 ){
				pos = ( (pos + count - 1 ) % ringSize) + 1;
				if( pos > k ){
					ringSize--;
					pos--;
				}else{
					break;
				}
				if( ringSize == k ){
					break;
				}
			}
			if( k == ringSize )
				return  count;
		}
		m++;
	}
}

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