#2TLE求调悬关
查看原帖
#2TLE求调悬关
1288333
XURUIFAN楼主2025/7/23 11:08

rt,码风不是很好,见谅。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef  pair<int, int> PII;
typedef  pair<ll, ll> PLL;
typedef  pair<int, ll> PIL;
#define mkp make_pair
#define F first
#define S second
#define psbk push_back

struct LL {
	int num[1010];
	int len;
	inline void init() {
		memset(num, 0, sizeof(num));
		len = 1;
	}
	inline void check() {
		for (int i = 1; i < 1009; i++) {
			num[i + 1] += num[i] / 10;
			num[i] %= 10;
		}
		len = 1009;
		while ((num[len] == 0) && (len > 1)) len--;
	}
	LL(ull x = 0) {
		init();
		for (int i = 1; x; i++) {
			num[i] += x % 10;
			x /= 10;
			len++;
		}
		check();
	}
	friend LL operator + (const LL &a, const LL &b) {
		LL ans(0);
		ans.len = max(a.len, b.len);
		for (int i = 1; i <= ans.len; i++) {
			ans.num[i] = a.num[i] + b.num[i];
		}
		ans.check();
		return ans;
	}
	friend LL operator *(const LL &a, const LL &b) {
		LL ans(0);
		ans.len = a.len + b.len;
		for (int i = 1; i <= a.len; i++) for (int j = 1; j <= b.len; j++) ans.num[i + j - 1] += a.num[i] * b.num[j];
		ans.check();
		return ans;
	}
};
ostream& operator << (ostream &out, LL a) {
	a.check();
	for (int i = a.len; i >= 1; i--) cout << a.num[i];
	return out;
}
int n;
LL a[510];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i <= n; i++) a[i].init();
	LL ne(1);
	a[0] = a[1] = ne;
	for (int i = 1; i < n; i++) for (int j = 0; j <= i; j++) a[i + 1] = a[i + 1] + a[j] * a[i - j];
	cout << a[n];
	return 0;
}
2025/7/23 11:08
加载中...