FB - DU LICH

20/08/2023

https://www.facebook.com/photo/?fbid=622509423343631&set=gm.657824342971940&idorvanity=208411111246601

Code
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define FILENAME "DATA"

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll mod = 1e9+7;
const ll oo = 1e18;
const int maxn = 1e3;

int n;
string f[maxn+1][maxn+1];

string cong(string a, string b) {
	while (a.length() < b.length()) a = "0" + a;
	while(b.length() < a.length()) b = "0" + b;
//	cout << a << " " << b << endl;
	string res;
	int nho = 0;
	int cong;
	char ch;
	int dig1, dig2;
	for (int i=a.length()-1;i >= 0;i--) {
		dig1 = a[i] - '0';
		dig2 = b[i] - '0';
		cong = dig1 + dig2 + nho;
		nho = cong/10;
		ch = (cong%10) + '0';
		res = ch + res;
	}
	if (nho != 0) {
		ch = (nho) + '0';
		if(ch != '0') res = ch + res;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	cin >> n;
	f[1][1] = "1";
	for (int i=2;i <= n;i++) {
		f[1][i] = "1";
		f[i][1] = "1";
	}

	for (int i=2;i <= n;i++) {
		for (int j=2;j <= n;j++)
			f[i][j] = cong(f[i-1][j], f[i][j-1]);
	}

	cout << f[n][n];

	return 0;
}

/*
1 1
2 2
3 6
4 20
5 70
6 252
7 924
8 3432
9 12870
10 48620
*/

// https://hieuhfgr.pythonanywhere.com/