int fib(int n){
if(n == 0)
return 0;
if(n == 1)
return 1;
int a[n+1];
a[0] = 0;
a[1] = 1;
for(int i = 2; i<=n; i++)
a[i] = (a[i-1] + a[i-2])%1000000007;
return a[n];
}
2024-03-24 21:27:52
int fib(int n){
if(n == 0)
return 0;
if(n == 1)
return 1;
int a[n+1];
a[0] = 0;
a[1] = 1;
for(int i = 2; i<=n; i++)
a[i] = (a[i-1] + a[i-2])%1000000007;
return a[n];
}
下一篇:计算斐波那契数列