文章目录
AcWing 741. 斐波那契数列
本题链接:AcWing 741. 斐波那契数列
本博客给出本题截图:
AC代码
注:会爆int
代码:
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
long long f[61];
f[0] = 0, f[1] = 1;
for (int i = 2; i <= 60; i ++ ) f[i] = f[i - 1] + f[i - 2];
int n;
cin >> n;
while (n -- )
{
int x;
cin >> x;
printf("Fib(%d) = %lld\n", x, f[x]);
}
return 0;
}