Mr_Snob @ 2020-12-12 23:17:15
第六个点一直WA 显示Too short on line one
by 夏米亚丁 @ 2020-12-13 09:56:13
@Mr_Snob 麻烦发一下代码
by 夏米亚丁 @ 2020-12-13 09:58:09
@Mr_Snob 这个数据很大,需要高精度
by Mr_Snob @ 2020-12-13 10:11:19
#include <iostream>
using namespace std;
struct way {
char number[10000];
};
way sum(way, way);
int main() {
int N = 0;
cin >> N;
way w[5001];
for (int i = 0; i < 5000; i++)
for (int j = 0; j < 10000; j++)
w[i].number[j] = '0';
w[1].number[0] = '1';
w[2].number[0] = '2';
for (int i = 3; i <= N; i++)
w[i] = sum(w[i - 1], w[i - 2]);
int i = 9999;
while (w[N].number[i] == '0')
i--;
for (int j = i; j >= 0; j--)
cout << w[N].number[j];
return 0;
}
way sum(way a, way b) {
way res;
int t = 0;
for (int i = 0; i < 10000; i++) {
res.number[i] = ((a.number[i] - '0') + (b.number[i] - '0') + t)%10+'0';
t = ((a.number[i] - '0') + (b.number[i] - '0') + t) / 10;
}return res;
}
谢谢宁