这个代码竟然连输出都没有,为神马?
#include<bits/stdc++.h>
using namespace std;
const int N = 4e4 + 5;
const int M = 2e3 + 5;
int a[M], b[M], c[M];
string f[N] = {"0", "1"};
string add(string a1, string b1)
{
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
int lena = a1.size(), lenb = b1.size(), lenc = 1, x = 0;
string ans = "";
for(int i = 0; i < lena; i ++)
a[lena - i] = a1[i] - 48;
for(int i = 0; i < lenb; i ++)
b[lenb - i] = b1[i] - 48;
while(lenc <= lena || lenc <= lenb)
{
c[lenc] = a[lenc] + b[lenc] + x;
x = c[lenc] / 10;
c[lenc] %= 10;
lenc ++;
}
c[lenc] = x;
if(c[lenc] == 0)
lenc --;
for(int i = lenc; i >= 1; i --)
ans += char(i + 48);
return ans;
}
int main()
{
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
if(n <= 1)
{
cout << f[n];
return 0;
}
for(int i = 2; i <= n; i ++)
f[n] = add(f[n - 1], f[n - 2]);
cout << f[n];
return 0;
}