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 |
我的方法超时,请各位看看可以怎样改进?(附程序)#include <stdio.h> int k=0; int main() { scanf("%d",&k); while(k!=0) { int n=2*k; long a=0,b=0,m=k,c=k; while(1) { b=(n-1+m+a)%n; if(b>=0&&b<=k-1) { m++; a=0; c=k; n=2*k; continue; } if(b>=n-1) a=0; else a=b; n--; c--; if(c==0) break; } printf("%d\n",m); scanf("%d",&k); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator