wyp20130701 @ 2024-07-22 12:17:39
#include <iostream>
using namespace std;
short f[5005][5500];
inline void jia(int p1,int p2,int p3)
{
short x = 0,len = 0;
for (int i = 1;i <= 5499;i++)
{
f[p3][i] = f[p1][i] + f[p2][i] + x;
x = f[p3][i] / 10;
f[p3][i] %= 10;
len++;
}
f[p3][len] = x;
return ;
}
inline void print(int n,int pos)
{
for (int i = 1;i <= pos;i++)
{
cout << f[n][i];
}
return ;
}
int main()
{
f[1][1] = 1;
f[2][1] = 2;
int n;
cin >> n;
for (int i = 3;i <= n;i++)
{
jia(i - 1,i - 2,i);
}
short pos = 5499;
while (f[n][pos] == 0)
{
pos--;
}
print(n,pos);
return 0;
}//f[x][y]表示数列第x项高精度第y位。
by wyp20130701 @ 2024-08-20 11:57:03
@yi105011 谢了已经过了
by wyp20130701 @ 2024-08-20 12:00:07
@poor_OIer 一维还得对每位进行初始化,二维空间可能大,但不需要对每位进行初始化。