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:终于不打表AC,282ms,放出代码,求更快的解法……In Reply To:终于不打表AC,282ms,放出代码,求更快的解法…… Posted by:alexneko at 2008-07-12 16:14:45 #include <stdio.h> void main() { int i,k,n; int people[13]; int now,count,total; for(i=0;i<13;i++) people[i]=0; scanf("%d",&k); while(k) { n=1; i=k+1; if(!people[k-1]) while(1) { now=count=0; total=2*k; if(i > 2*n*k) { i = 2*n*k+k+1; n++; } while(count < k) { now=(now+i-1) % total; if(now < k) break; count++; total--; } if(count == k) { people[k-1]=i; break; } i++; } printf("%d\n",people[k-1]); scanf("%d",&k); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator