Topic Link http://vjudge.net/problem/21247
Test instructions to a, B. Number of FIB numbers in [A, B].
Thinking of solving problems
Direct high-precision simulation
Code
#include <stdio.h>#include<string.h>#defineMax_size 110#defineMax_len 1010CharA[max_size], b[max_size];intF[max_len][max_size];intLen[max_len];intcmpint*x,Char*y,intm) { inti =0; if(M < strlen (y))return-1; if(M > strlen (y))return 1; while(I < m && x[max_size-m+i] = = Y[i]-'0') i++; if(i = = m)return 0; returnX[max_size-m+i]-y[i] +'0';}voidAddint*res,int*x,int*y,intLenx,intLeny,intindex) { intm = lenx > Leny?Lenx:leny; inti =1; intK =0; Len[index]=m; while(I <=m) {res[max_size-I] = X[max_size-i] + y[max_size-i] +K; K= Res[max_size-i]/Ten; Res[max_size-I.]%=Ten; I++; } if(k! =0) {Res[max_size-i] = k; len[index]++; }}intMain () {scanf ("%s%s", A, b); while(! (a[0] =='0'&& b[0] =='0') ) {f[1][max_size-1] =1; len[1] =1; f[2][max_size-1] =2; len[2] =1; inti =1; intCount =0; Do { if(CMP (F[i], A, len[i]) >=0) count++; I++; if(I >=3) Add (F[i], f[i-1], f[i-2], len[i-1], len[i-2], i); } while(CMP (F[i], B, len[i]) <=0); printf ("%d\n", Count); scanf ("%s%s", A, b); } return 0;}
uva10183-how many fib