| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:总结三点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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator