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 |
功力深厚的大哥,我调了一下午了,试了很多数据,搞不定。。。。提交还是WA。。。help me !!#include<stdio.h> #include<string.h> int com(char a[],char b[]) { int m,n,k; for(m=0;a[m]!='\0';m++); for(n=0;b[n]!='\0';n++); if(m<n) return 0; if(m==n) { for(k=m-1;k>=0;k--) { if(a[k]<b[k]) return 0; if(a[k]>b[k]) return 1; } if(k==-1) return 1; } if(m>n) return 1; } void main() { char fib[480][120]; char s1[120],s2[120],s3[120],s4[120]; int i,j,count; strcpy(fib[0],"1"); strcpy(fib[1],"2"); for(i=2;i<480;i++) { strcpy(s1,fib[i-1]); for(j=0;fib[i-2][j]!='\0';j++) s1[j]+=fib[i-2][j]-'0'; for(j=0;s1[j+1]!='\0';j++) { s1[j+1]+=(int)(s1[j]-'0')/10; s1[j]=(int)(s1[j]-'0')%10+'0'; } if(s1[j]>=(10+'0')) { s1[j+2]='\0'; s1[j+1]=(int)(s1[j]-'0')/10+'0'; s1[j]=(int)(s1[j]-'0')%10+'0'; } strcpy(fib[i],s1); } while(1) { scanf("%s%s",s1,s2); if(strcmp(s1,"0")==0) break; strcpy(s3,s1); strcpy(s4,s2); strrev(s3); strrev(s4); for(i=0;;i++) if(com(fib[i],s3)) break; count=0; for(j=i;;j++) if(com(s4,fib[j])) count++; else break; printf("%d\n",count); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator