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> #define bool _Bool #define true 1 #define false 0 int n; bool have[150]; bool last; int main() { int i; while(scanf("%d",&n)&&n!=0) { for(i=2;;i++) { memset(have,0,sizeof(have)); last=false; ///本来是next()函数,由于超时,所以拿出来,不过还是TLE!!!,有空再看 int _i,c=1,_j,cnt=0; int _cnt=0; have[c]=true; //printf("%d\n",c); _cnt++; for(_i=0;_i<n;_i++) { for(_j=0;_j<i;_j++) { while(have[(c+1)%n]==true) { c=(c+1)%n; cnt++; if(cnt>n) goto nextstep; } cnt=0; c=(c+1)%n; } have[c]=true; if(c==0) c+=n; //printf("%d\n",c); _cnt++; if(_cnt==n&&c==2) last=true; } //////////////// nextstep:if(last==true) { printf("%d\n",i); break; } } } return 0; } 只好打表! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator