CodeForces - 1288C Two Arrays 组合数学

Two Arrays

在这里插入图片描述

input

723 9

ouput

157557417

code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int N = 3e5+10;
const int MOD = 1e9 + 7;
//
int n, m, f[N];
ll temp;
//
ll quick_pow(ll ans, ll p, ll res = 1) {
    
    
	for(; p; p >>= 1, ans = ans * ans % MOD) 
		if(p & 1) res = res * ans % MOD;
	return res % MOD;
}
ll inv(ll ans) {
    
    
	return quick_pow(ans, MOD - 2) % MOD;
}
ll C(int n, int m) {
    
    
	return 1ll * f[n] * inv(f[n - m]) % MOD * inv(f[m]) % MOD;
}
inline void solve(ll res = 0, ll ans = 0) {
    
    
	res = C(2 * m + n - 1, 2 * m);
	cout << res << endl;
}
int main() {
    
    
	f[0] = f[1] = 1;
	for(int i = 2; i < N; ++ i) 
		f[i] = 1ll * f[i - 1] * i % MOD;
	cin >> n >> m;
	solve();
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/qq_46173805/article/details/114268963