mnzn求助qaq,四彩斑斓,15pts
查看原帖
mnzn求助qaq,四彩斑斓,15pts
360265
Galois_Field_1048576楼主2021/11/20 21:16

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 1e2 + 5;
struct Bigg {
	int a[N], length;
	void init() {
		memset(a, 0, sizeof a);
		length = 1;
	}
};
ostream& operator << (ostream& out, const Bigg& a) {
	cout << a.a[a.length];
	for (int i = a.length - 1; i >= 1; i--) cout << a.a[i];
	return out;
}
Bigg operator+ (Bigg m, Bigg n) {
	Bigg ans;
	int u = m.length, v = n.length;
	int maxDigit = max(u,v);
	int q = 0, temp;
	for (int i = 1; i <= maxDigit; i++) {
		ans.a[i] = m.a[i] + n.a[i] + q;
		q = ans.a[i] / 10;
		ans.a[i] %= 10;
	}
	if (q >= 1) 
		ans.a[maxDigit] = q, maxDigit++;
	ans.length = maxDigit;
	//cout << m << "+" << n << "=" << ans << endl;
	return ans;
}
int n, g[N][N];
Bigg f[N][N];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> g[i][j], f[i][j].init();
	g[n][n] = 1; f[1][1].length = 1, f[1][1].a[1] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			//cout << f[1][1] << ' ' << f[i][j] << endl;
			if (i + g[i][j] <= n) f[i + g[i][j]][j] = f[i][j] + f[i + g[i][j]][j];
			if (j + g[i][j] <= n) f[i][j + g[i][j]] = f[i][j] + f[i][j + g[i][j]];
		}
	cout << f[n][n];
	return 0;
}

Bigg结构体bzd有没有问题

2021/11/20 21:16
加载中...