bzoj 1856 卡特兰数

复习了一下卡特兰数。。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PII pair<int, int>
#define y1 skldjfskldjg
#define y2 skldfjsklejg
using namespace std;

const int N = 2e6 + 7;
const int M = 5e5 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 20100403;
const int B = 1e5;

int n, m;
LL inv[N], comb[N];

void init(int n) {
    inv[1] = 1;
    for(int i = 2; i <= n; i++)
        inv[i] = (mod-mod/i) * inv[mod%i] % mod;
    comb[0] = 1;
    for(int i = 1; i <= n; i++)
        comb[i] = comb[i - 1] * (n - i + 1) % mod * inv[i] % mod;
}

int main() {
    scanf("%d%d", &n, &m);
    init(n + m);
    if(m > n) {
        puts("0");
    } else {
        printf("%lld\n", (comb[m] - comb[m - 1] + mod) % mod);
    }
    return 0;
}

 

posted @ 2018-09-07 00:36  NotNight  阅读(126)  评论(0编辑  收藏  举报