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 |
这不怪你,这只能怪数据太弱In Reply To:为什么我没TLE啊,并且还是0ms Posted by:lst at 2009-10-11 16:26:22 > #include <stdio.h> > #include <string> > char c[83681][6]={{},{"a"},{"b"},{"c"},{"d"},{"e"},{"f"},{"g"},{"h"},{"i"},{"j"},{"k"},{"l"},{"m"},{"n"},{"o"},{"p"},{"q"},{"r"},{"s"},{"t"},{"u"},{"v"},{"w"},{"x"},{"y"},{"z"}}; > int n=27; > char t[6]; > void f2() > { > int i,j; > for(i='a';i<='z';i++) > { > for(j=i+1;j<='z';j++) > { > t[0]=i; > t[1]=j; > strcpy(c[n++],t); > } > > } > } > void f3() > { > int i,j,k; > for(i='a';i<='z';i++) > { > for(j=i+1;j<='z';j++) > { > for(k=j+1;k<='z';k++) > { > t[0]=i;t[1]=j;t[2]=k;strcpy(c[n++],t); > } > } > } > } > void f4() > { > int i,j,k,l; > for(i='a';i<='z';i++) > { > for(j=i+1;j<='z';j++) > { > for(k=j+1;k<='z';k++) > { > for(l=k+1;l<='z';l++) > { > t[0]=i;t[1]=j;t[2]=k;t[3]=l;strcpy(c[n++],t); > } > } > } > } > } > void f5() > { > int i,j,k,l,m; > for(i='a';i<='z';i++) > { > for(j=i+1;j<='z';j++) > { > for(k=j+1;k<='z';k++) > { > for(l=k+1;l<='z';l++) > { > for(m=l+1;m<='z';m++) > { > t[0]=i;t[1]=j;t[2]=k;t[3]=l;t[4]=m;strcpy(c[n++],t); > } > } > } > } > } > } > int main() > { > int i; > f2();f3();f4();f5(); > while(scanf("%s",t)!=EOF) > { > int flag=0; > for(i=1;i<=83681;i++) > { > if(strcmp(t,c[i])==0) > { > flag=1; > printf("%d\n",i); > break; > } > } > if(flag==0) > printf("0\n"); > } > return 0; > } > 我打表26*25*24*23*22=7893600的复杂度,再加上我查询O(83681n)的复杂度怎么样都应该超时啊 > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator