杨辉三角求组合数模板

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <cstring>
 5 #include <string>
 6 using namespace std;
 7 typedef long long ll;
 8 const int maxn = 2000+10;
 9 const int mod = 998244353;
10 const int inf = 0x3f3f3f3f;
11 #define rep(i,first,second) for(ll i=first;i<=second;i++)
12 #define dep(i,first,second) for(ll i=first;i>=second;i--)
13 #define erep(i,u) for(ll i=head[u];~i;i=e[i].nxt)
14 #define lowbit(i) i&(-i)
15 
16 int a[maxn][maxn];
17 void init(){
18     rep(i,1,2000){
19         a[i][0]=a[i][i]=1;
20         rep(j,1,i-1){
21             a[i][j]=(a[i-1][j]+a[i-1][j-1])%mod;
22         }
23     }
24 }
25 int main()
26 {
27     init();
28     int n,m;
29     while(~scanf("%d%d",&n,&m)){
30         printf("%d
",a[n][m]);
31     }
32     return 0;
33 }
原文地址:https://www.cnblogs.com/wsy107316/p/12810023.html