RoyWu1207 @ 2022-07-02 13:28:42
#include<iostream>
using namespace std;
int gj[1001] = { 1 }, last[1001] = { 2 }, len = 1;
int main( ) {
int n; cin >> n;
if ( n == 1 ) {
cout << 1;
return 0;
} if ( n == 2 ) {
cout << 2;
return 0;
}
for ( int i = 3; i <= n; i++ ) {
for ( int j = 0; j < len; j++ )
gj[j] += last[j], gj[j+1] += gj[j] / 10, gj[j] %= 10;
if ( gj[len] )
len++;
swap( gj, last );
}
for ( int i = len - 1; i >= 0; i-- )
cout << last[i];
return 0;
}
by Untitled10032 @ 2022-07-02 13:54:42
数组开小了(好像输入5000的时候输出有1045位)
by 梁家豪12345 @ 2022-07-02 17:02:09
@Untitled10032
long long
好像只有19位,本题范围太大,位数是
long long
的55倍