题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1316
题目大意:给出两个数,求两个数之间有多少个斐波那契数。
解题思路:通过打表的方式将斐波那契数求到10^100,大概450个左右,然后找到给出的两个数的下标(前后大小不一定)。
模板连接:http://blog.csdn.net/keshuai19940722/article/details/10087993
#include <math.h> #include <stdlib.h> int main() { int n, f, e; char str1[N], str2[N]; bign num[500], over = 0; num[1] = 1; num[2] = 2; for (int i = 3; i < 500; i++) num[i] = num[i - 1] + num[i - 2]; while (cin >> str1 >> str2) { bign a = str1, b = str2; if (a == over && b == over) break; f = e = 0; for (int i = 1; i < n; i++) { if (!f && num[i] >= a) f = i; if (!e && num[i] > b) e = i; if (f && e) break; } cout << abs(e - f) << endl; } return 0; }