标签:
【数据范围】
对于30%的数据,保证1<=m<=n<=1000
对于100%的数据,保证1<=m<=n<=1000000
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> using namespace std; const int mod = 20100403; long long ans; int n, m; void exgcd(long long a, long long b, long long & x, long long &y) { if (b == 0) { x = 1; y = 0; } else { exgcd(b, a%b, x, y); long long t = x; x = y; y = t - a / b * y; } } long long niyuan(long long a, long long p) { long long x, y; exgcd(a, p, x, y); x = (x + mod) % mod; return x; } long long Sum(long long x) { long long temp = 1; for (int i = 1; i <= x; i++) { temp = (temp * i) % mod; } return temp; } long long C(long long x, long long y) { long long a, b, c; a = Sum(x); b = Sum(y); c = Sum(x - y); return a * niyuan(b, mod) % mod * niyuan(c, mod) % mod; } int main() { scanf("%d%d", &n, &m); ans = (C(n + m, n) - C(n + m, n + 1) + mod) % mod; printf("%lld", ans); return 0; }
标签:
原文地址:http://www.cnblogs.com/zbtrs/p/5785553.html