计科1802晁琪洛 @ 2020-01-14 10:38:53
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n;
vector<vector<char>> a(5001);
cin >> n;
a[0].push_back('0');
a[1].push_back('1');
a[2].push_back('2');
int nn, t = 0;
string temp;
for (int i = 2; i < n; i++)
{
nn = a[i].size() > a[i - 1].size() ? a[i].size() : a[i - 1].size();
for (int j = 0; j <= nn; j++)
{
if (j == nn && t == 0)
break;
if (j < a[i - 1].size() && j < a[i].size())
t += a[i - 1][j] + a[i][j] - '0';
if (j >= a[i - 1].size() && j < a[i].size())
t += a[i][j];
if (j < a[i - 1].size() && j >= a[i].size())
t += a[i - 1][j];
if (j >= a[i - 1].size() && j >= a[i].size())
t += '0';
a[i + 1].push_back((t - '0') % 10 + '0');
t = (t - '0') / 10;
}
}
for(int j=0;j<a[n].size();j++)
cout << a[n][a[n].size()-j-1];
return 0;
}
by 计科1802晁琪洛 @ 2020-01-14 10:40:39
emmmm,循环那块要是用else if的话更优一些
by JRzyh @ 2020-05-24 18:44:08
?
by Genshin_de_servant @ 2020-11-23 22:00:29
好秀啊