https://atcoder.jp/contests/abc132/tasks/abc132_d

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
int n, b;
long long MOD = 1e9 + 7;
class fastio {
public:
fastio() {
ios_base::sync_with_stdio(false);
cout.tie(nullptr);
cin.tie(nullptr);
}
} __fastio;
int C(int n, int k) {
int dp[n+1][k+1];
for(int i=0; i<=n; i++) {
for(int j=0; j<= min(i,k); j++) {
if (j == 0 || j == i)
dp[i][j] = 1;
else
dp[i][j] = dp[i - 1][j - 1] +
dp[i - 1][j];
}
}
return dp[n][k];
}
void solve() {
cin >> n >> b;
int r = n - b;
int ans = 0;
for(int i=1; i<=b; i++) {
ans = (C(b-1, i-1) * C(r+1, i)) % MOD;
cout << ans << endl;
}
}
int main() {
__fastio;
solve();
return 0;
}