http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=259#problem/C
Description
Recall the definition of the Fibonacci numbers:
f1 := 1
f2 := 2
fn := fn-1 + fn-2 (n >= 3)
Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b].
f1 := 1
f2 := 2
fn := fn-1 + fn-2 (n >= 3)
Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b].
Input
The input contains several test cases. Each test case consists of two
non-negative integer numbers a and b. Input is terminated by a = b = 0.
Otherwise, a <= b <= 10^100. The numbers a and b are given with no
superfluous leading zeros.
Output
For each test case output on a single line the number of Fibonacci numbers fi with a <= fi <= b.
Sample Input
10 100
1234567890 9876543210
0 0
Sample Output
5
4
#include <stdio.h> #include <string.h> #include <stdlib.h> int a[601][1000]; char str[601][1001]; int main() { char m[601],n[601]; int i,j,sum; memset(a,0,sizeof(a));//大数斐波那契,主要是了解思想 a[1][0]=1; a[2][0]=2; a[3][0]=3; for (i=4;i<=600;i++) { for (j=0;j<=501;j++) { a[i][j]=a[i][j]+a[i-1][j]+a[i-2][j]; if (a[i][j]>9) { a[i][j+1]=a[i][j]/10; a[i][j]=a[i][j]%10; } } } int flag=0,k; for(int i=1;i<=600;i++) { flag=0; k=0; for(int j=500;j>=0;j--) { if(flag||a[i][j]) { flag=1; str[i][k]=a[i][j]+'0'; k++; } } str[i][k]='