problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p02989 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
if (a[n / 2 + 1] == a[n / 2])
cout << "0" << endl;
else
cout << a[n / 2 + 1] - a[n / 2] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
if (a[n / 2 - 1] == a[n / 2])
cout << "0" << endl;
else
cout << a[n / 2] - a[n / 2 - 1] << endl;
return 0;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 797,092 | 797,093 | u640323045 | cpp |
p02989 | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> d(n);
for (int i = 0; i < n; ++i) {
cin >> d[i];
}
sort(d.begin(), d.end());
int res = d[n / 2 + 1] - d[n / 2];
cout << res << "\n";
return 0;
} | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> d(n);
for (int i = 0; i < n; ++i) {
cin >> d[i];
}
sort(d.begin(), d.end());
int res = d[n / 2] - d[n / 2 - 1];
cout << res << "\n";
return 0;
}
| [
"expression.operation.binary.remove"
] | 797,100 | 797,101 | u640255289 | cpp |
p02989 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int n;
cin >> n;
int num[n];
int ans;
for (int i = 0; i < n; i++)
cin >> num[i];
sort(num, num + n);
if (num[n / 2 + 1] == num[n / 2])
ans = 0;
else
ans = num[n / 2] - num[n / 2 - 1];
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int n;
cin >> n;
int num[n];
int ans;
for (int i = 0; i < n; i++)
cin >> num[i];
sort(num, num + n);
if (num[n / 2] == num[n / 2 - 1])
ans = 0;
else
ans = num[n / 2] - num[n / 2 - 1];
cout << ans << endl;
return 0;
} | [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 797,119 | 797,120 | u157195505 | cpp |
p02989 | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <map>
#include <random>
#include <set>
#include <stdio.h>
#include <time.h>
#include <unordered_set>
#include <vector>
#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;
typedef long long ll;
typedef long double dbl;
template <class T> void print(vector<T> s) {
for (T x : s)
cout << x << " ";
cout << endl;
}
void solve() {}
int main() {
srand(17);
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("a.in", "r", stdin);
int n;
cin >> n;
vector<int> s(n);
for (int i = 0; i < n; i++)
cin >> s[i];
sort(s.begin(), s.end());
// cout << s[n / 2] << endl;
cout << s[n / 2] - s[n / 2 - 1] + 1 << endl;
} | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <map>
#include <random>
#include <set>
#include <stdio.h>
#include <time.h>
#include <unordered_set>
#include <vector>
#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;
typedef long long ll;
typedef long double dbl;
template <class T> void print(vector<T> s) {
for (T x : s)
cout << x << " ";
cout << endl;
}
void solve() {}
int main() {
srand(17);
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("a.in", "r", stdin);
int n;
cin >> n;
vector<int> s(n);
for (int i = 0; i < n; i++)
cin >> s[i];
sort(s.begin(), s.end());
// cout << s[n / 2] << endl;
cout << s[n / 2] - s[n / 2 - 1] << endl;
} | [
"expression.operation.binary.remove"
] | 797,166 | 797,167 | u485550995 | cpp |
p02989 | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <map>
#include <random>
#include <set>
#include <stdio.h>
#include <time.h>
#include <unordered_set>
#include <vector>
#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;
typedef long long ll;
typedef long double dbl;
template <class T> void print(vector<T> s) {
for (T x : s)
cout << x << " ";
cout << endl;
}
void solve() {}
int main() {
srand(17);
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("a.in", "r", stdin);
int n;
cin >> n;
vector<int> s(n);
for (int i = 0; i < n; i++)
cin >> s[i];
sort(s.begin(), s.end());
cout << s[n / 2 + 1] - s[n / 2] + 1 << endl;
} | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <map>
#include <random>
#include <set>
#include <stdio.h>
#include <time.h>
#include <unordered_set>
#include <vector>
#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;
typedef long long ll;
typedef long double dbl;
template <class T> void print(vector<T> s) {
for (T x : s)
cout << x << " ";
cout << endl;
}
void solve() {}
int main() {
srand(17);
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("a.in", "r", stdin);
int n;
cin >> n;
vector<int> s(n);
for (int i = 0; i < n; i++)
cin >> s[i];
sort(s.begin(), s.end());
// cout << s[n / 2] << endl;
cout << s[n / 2] - s[n / 2 - 1] << endl;
} | [
"expression.operation.binary.remove",
"variable_access.subscript.index.change",
"io.output.change"
] | 797,168 | 797,167 | u485550995 | cpp |
p02989 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int s = n / 2;
cout << a[s + 1] - a[s] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int s = n / 2;
cout << a[s] - a[s - 1] << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 797,205 | 797,206 | u127361799 | cpp |
p02989 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> d(n);
for (int i = 0; i < n; i++)
cin >> d[i];
sort(d.begin(), d.end());
cout << d[n / 2 + 1] - d[n / 2] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> d(n);
for (int i = 0; i < n; i++)
cin >> d[i];
sort(d.begin(), d.end());
cout << d[n / 2] - d[n / 2 - 1] << endl;
} | [
"expression.operation.binary.remove"
] | 797,207 | 797,208 | u370447425 | cpp |
p02989 | #include <bits/stdc++.h>
using namespace std;
int a[100010], n;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a, a + n);
cout << a[n / 2 + 1] - a[n / 2];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int a[100010], n;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(a, a + n + 1);
cout << a[n / 2 + 1] - a[n / 2];
return 0;
} | [
"expression.operation.binary.add"
] | 797,224 | 797,225 | u260168182 | cpp |
p02989 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
sort(a.begin(), a.end());
cout << a.at(n - 1) - a.at(n - 2) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
sort(a.begin(), a.end());
cout << a.at(n / 2) - a.at(n / 2 - 1) << endl;
}
| [
"expression.operator.arithmetic.change",
"io.output.change"
] | 797,242 | 797,243 | u577552796 | cpp |
p02989 | #include <iostream>
#include <vector>
using namespace std;
typedef long value_type; /* ソートするキーの型 */
/* x, y, z の中間値を返す */
value_type med3(value_type x, value_type y, value_type z) {
if (x < y) {
if (y < z)
return y;
else if (z < x)
return x;
else
return z;
} else {
if (z < y)
return y;
else if (x < z)
return x;
else
return z;
}
}
/* クイックソート
* a : ソートする配列
* left : ソートするデータの開始位置
* right : ソートするデータの終了位置
*/
void quicksort(value_type a[], long left, long right) {
if (left < right) {
long i = left, j = right;
value_type tmp,
pivot = med3(a[i], a[i + (j - i) / 2],
a[j]); /* (i+j)/2 ではオーバーフローしてしまう */
while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
while (a[i] < pivot)
i++; /* a[i] >= pivot となる位置を検索 */
while (pivot < a[j])
j--; /* a[j] <= pivot となる位置を検索 */
if (i >= j)
break;
tmp = a[i];
a[i] = a[j];
a[j] = tmp; /* a[i], a[j] を交換 */
i++;
j--;
}
quicksort(a, left, i - 1); /* 分割した左を再帰的にソート */
quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
}
}
int main() {
long N;
cin >> N;
long *d;
d = (long *)malloc(N * sizeof(long));
for (long i = 0; i < N; i++)
cin >> d[i];
quicksort(d, 0, N - 1);
cout << d[N / 2 - 1] - d[N / 2 + 1] << endl;
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
typedef long value_type; /* ソートするキーの型 */
/* x, y, z の中間値を返す */
value_type med3(value_type x, value_type y, value_type z) {
if (x < y) {
if (y < z)
return y;
else if (z < x)
return x;
else
return z;
} else {
if (z < y)
return y;
else if (x < z)
return x;
else
return z;
}
}
/* クイックソート
* a : ソートする配列
* left : ソートするデータの開始位置
* right : ソートするデータの終了位置
*/
void quicksort(value_type a[], long left, long right) {
if (left < right) {
long i = left, j = right;
value_type tmp,
pivot = med3(a[i], a[i + (j - i) / 2],
a[j]); /* (i+j)/2 ではオーバーフローしてしまう */
while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
while (a[i] < pivot)
i++; /* a[i] >= pivot となる位置を検索 */
while (pivot < a[j])
j--; /* a[j] <= pivot となる位置を検索 */
if (i >= j)
break;
tmp = a[i];
a[i] = a[j];
a[j] = tmp; /* a[i], a[j] を交換 */
i++;
j--;
}
quicksort(a, left, i - 1); /* 分割した左を再帰的にソート */
quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
}
}
int main() {
long N;
cin >> N;
long *d;
d = (long *)malloc(N * sizeof(long));
for (long i = 0; i < N; i++)
cin >> d[i];
quicksort(d, 0, N - 1);
cout << d[N / 2] - d[N / 2 - 1] << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 797,247 | 797,248 | u344977358 | cpp |
p02990 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9 + 100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll modinv(ll x) { return modpow(x, mod - 2); }
ll comb(ll n, ll k) {
ll ans1 = 1;
ll ans2 = 1;
rep(i, 0, k) ans1 = ans1 * (n - i) % mod;
rep(i, 0, k) ans2 = ans2 * (i + 1) % mod;
return ans1 * modinv(ans2) % mod;
}
int main() {
FIN;
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << comb(n - k + 1, i) * comb(k - 1, i - 1) << endl;
}
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9 + 100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll modinv(ll x) { return modpow(x, mod - 2); }
ll comb(ll n, ll k) {
ll ans1 = 1;
ll ans2 = 1;
rep(i, 0, k) ans1 = ans1 * (n - i) % mod;
rep(i, 0, k) ans2 = ans2 * (i + 1) % mod;
return ans1 * modinv(ans2) % mod;
}
int main() {
FIN;
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << (comb(n - k + 1, i) * comb(k - 1, i - 1)) % mod << endl;
}
return 0;
}
| [
"expression.operation.binary.add"
] | 797,263 | 797,264 | u756784272 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
int c(int n, int r) {
const int mod = 1000000007;
long long x = 1, g = 1;
for (int i = 1; i <= r; i++) {
x *= (n - i + 1);
x %= mod;
g *= i;
g %= mod;
}
long long pow = g;
g = 1;
for (int i = mod - 2; i > 0; i /= 2) {
if (i % 2)
g *= pow;
g %= mod;
pow *= pow;
pow %= mod;
}
x *= g;
x %= mod;
return x;
}
int main() {
const int mod = 1000000007;
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
//並べ方: n-k+1 C i ,分け方: k-1 C i-1
if (n - k + 1 < i)
cout << "0" << endl;
else
cout << c(n - k + 1, i) * c(k - 1, i - 1) % mod << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long c(int n, int r) {
const int mod = 1000000007;
long long x = 1, g = 1;
for (int i = 1; i <= r; i++) {
x *= (n - i + 1);
x %= mod;
g *= i;
g %= mod;
}
long long pow = g;
g = 1;
for (int i = mod - 2; i > 0; i /= 2) {
if (i % 2)
g *= pow;
g %= mod;
pow *= pow;
pow %= mod;
}
x *= g;
x %= mod;
return x;
}
int main() {
const int mod = 1000000007;
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
//並べ方: n-k+1 C i ,分け方: k-1 C i-1
if (n - k + 1 < i)
cout << "0" << endl;
else
cout << c(n - k + 1, i) * c(k - 1, i - 1) % mod << endl;
}
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 797,265 | 797,266 | u507850687 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9 + 7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;
//
// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// 逆元 a^{-1} mod を計算する
ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); }
const int MAX = 3000000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理(main内にCOMinit();が必要)
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
ll COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n, k;
cin >> n >> k;
COMinit();
rep(i, 1, k + 1) { cout << COM(n - k + 1, i) * COM(k - 1, i - 1) << endl; }
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9 + 7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;
//
// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// 逆元 a^{-1} mod を計算する
ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); }
const int MAX = 3000000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理(main内にCOMinit();が必要)
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
ll COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n, k;
cin >> n >> k;
COMinit();
rep(i, 1, k + 1) {
cout << (COM(n - k + 1, i) * COM(k - 1, i - 1)) % MOD << endl;
}
} | [
"expression.operation.binary.add"
] | 797,277 | 797,278 | u646962247 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d", &x);
ll mpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll fac(int n, ll mod) {
if (n == 1 || n == 0)
return 1;
return n * fac(n - 1, mod) % mod;
}
ll solve(int n, int i, int k) {
ll x1, x2, x3, tmp, mod = 1e9 + 7;
if (k == 0)
x1 = 1ll;
else {
tmp = fac(k - 1 - i, mod) * fac(i, mod) % mod;
x1 = fac(k - 1, mod) * mpow(tmp, mod - 2, mod) % mod;
}
x3 = fac(n - k + 1, mod);
tmp = fac(i + 1, mod) * fac(n - k - i, mod) % mod;
x2 = x3 * mpow(tmp, mod - 2, mod) % mod;
return x1 * x2 % mod;
}
int main() {
int n, k;
sc(n) sc(k) for (int i = 0; i < k; i++) {
if (n - k - i < 0)
cout << 0 << endl;
cout << solve(n, i, k) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d", &x);
ll mpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll fac(int n, ll mod) {
if (n == 1 || n == 0)
return 1;
return n * fac(n - 1, mod) % mod;
}
ll solve(int n, int i, int k) {
ll x1, x2, x3, tmp, mod = 1e9 + 7;
if (k == 0)
x1 = 1ll;
else {
tmp = fac(k - 1 - i, mod) * fac(i, mod) % mod;
x1 = fac(k - 1, mod) * mpow(tmp, mod - 2, mod) % mod;
}
x3 = fac(n - k + 1, mod);
tmp = fac(i + 1, mod) * fac(n - k - i, mod) % mod;
x2 = x3 * mpow(tmp, mod - 2, mod) % mod;
return x1 * x2 % mod;
}
int main() {
int n, k;
sc(n) sc(k) for (int i = 0; i < k; i++) {
if (n - k - i < 0)
cout << 0 << endl;
else
cout << solve(n, i, k) << endl;
}
return 0;
} | [
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add"
] | 797,279 | 797,280 | u920543723 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d", &x);
ll mpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll fac(int n, ll mod) {
if (n == 1 || n == 0)
return 1;
return n * fac(n - 1, mod) % mod;
}
ll solve(int n, int i, int k) {
ll x1, x2, x3, tmp, mod = 1e9 + 7;
if (k == 0)
x1 = 1ll;
else {
tmp = fac(k - 1 - i, mod) * fac(i, mod) % mod;
x1 = fac(k - 1, mod) * mpow(tmp, mod - 2, mod) % mod;
}
x3 = fac(n - k + 1, mod);
tmp = fac(i + 1, mod) * fac(n - k - i, mod) % mod;
x2 = x3 * mpow(tmp, mod - 2, mod) % mod;
return x1 * x2 % mod;
}
int main() {
int n, k;
sc(n) sc(k) for (int i = 0; i < k; i++) {
if (n - k < i)
cout << 0 << endl;
cout << solve(n, i, k) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d", &x);
ll mpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll fac(int n, ll mod) {
if (n == 1 || n == 0)
return 1;
return n * fac(n - 1, mod) % mod;
}
ll solve(int n, int i, int k) {
ll x1, x2, x3, tmp, mod = 1e9 + 7;
if (k == 0)
x1 = 1ll;
else {
tmp = fac(k - 1 - i, mod) * fac(i, mod) % mod;
x1 = fac(k - 1, mod) * mpow(tmp, mod - 2, mod) % mod;
}
x3 = fac(n - k + 1, mod);
tmp = fac(i + 1, mod) * fac(n - k - i, mod) % mod;
x2 = x3 * mpow(tmp, mod - 2, mod) % mod;
return x1 * x2 % mod;
}
int main() {
int n, k;
sc(n) sc(k) for (int i = 0; i < k; i++) {
if (n - k - i < 0)
cout << 0 << endl;
else
cout << solve(n, i, k) << endl;
}
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add"
] | 797,281 | 797,280 | u920543723 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a, n) for (int i = a; i < n; i++)
#define rep1(a, n) for (int i = a; i <= n; i++)
#define bada 1000000007
int c[2001][2001];
int main() {
for (int i = 0; i <= 2000; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++) {
c[i][j] = (c[i - 1][j]) + (c[i - 1][j - 1]);
c[i][j] %= bada;
}
}
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++)
cout << (c[n + k - 1][i] * c[k - 1][i - 1]) % bada << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a, n) for (int i = a; i < n; i++)
#define rep1(a, n) for (int i = a; i <= n; i++)
#define bada 1000000007
ll c[2001][2001];
int main() {
for (int i = 0; i <= 2000; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++) {
c[i][j] = (c[i - 1][j]) + (c[i - 1][j - 1]);
c[i][j] %= bada;
}
}
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++)
cout << (c[n - k + 1][i] * c[k - 1][i - 1]) % bada << "\n";
return 0;
}
| [
"variable_declaration.type.change",
"expression.operation.binary.remove"
] | 797,282 | 797,283 | u507549471 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a, n) for (int i = a; i < n; i++)
#define rep1(a, n) for (int i = a; i <= n; i++)
#define bada 1000000007
ll c[2001][2001];
int main() {
for (int i = 0; i <= 2000; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++) {
c[i][j] = (c[i - 1][j]) + (c[i - 1][j - 1]);
c[i][j] %= bada;
}
}
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++)
cout << (c[n + k - 1][i] * c[k - 1][i - 1]) % bada << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a, n) for (int i = a; i < n; i++)
#define rep1(a, n) for (int i = a; i <= n; i++)
#define bada 1000000007
ll c[2001][2001];
int main() {
for (int i = 0; i <= 2000; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++) {
c[i][j] = (c[i - 1][j]) + (c[i - 1][j - 1]);
c[i][j] %= bada;
}
}
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++)
cout << (c[n - k + 1][i] * c[k - 1][i - 1]) % bada << "\n";
return 0;
}
| [
"expression.operation.binary.remove"
] | 797,284 | 797,283 | u507549471 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
int r = n - k + 1;
// cout << COM(1998, 1) * COM(2, 2) << endl;
// cout << COM(1998, 2) * COM(2, 1) << endl;
// cout << COM(1998, 3) * COM(2, 0) << endl;
for (int i = 1; i <= k; ++i) {
cout << COM(r, i) * COM(k - 1, k - i) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
int r = n - k + 1;
// cout << COM(1998, 1) * COM(2, 2) << endl;
// cout << COM(1998, 2) * COM(2, 1) << endl;
// cout << COM(1998, 3) * COM(2, 0) << endl;
for (int i = 1; i <= k; ++i) {
cout << COM(r, i) * COM(k - 1, k - i) % MOD << endl;
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,285 | 797,286 | u189867560 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
int r = n - k + 1;
// cout << COM(1998, 1) * COM(2, 2) << endl;
// cout << COM(1998, 2) * COM(2, 1) << endl;
// cout << COM(1998, 3) * COM(2, 0) << endl;
for (int i = 1; i <= k; ++i) {
cout << COM(r, i) * COM(k - 1, i - 1) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
int r = n - k + 1;
// cout << COM(1998, 1) * COM(2, 2) << endl;
// cout << COM(1998, 2) * COM(2, 1) << endl;
// cout << COM(1998, 3) * COM(2, 0) << endl;
for (int i = 1; i <= k; ++i) {
cout << COM(r, i) * COM(k - 1, k - i) % MOD << endl;
}
return 0;
} | [
"identifier.change",
"io.output.change",
"identifier.replace.add",
"literal.replace.remove"
] | 797,287 | 797,286 | u189867560 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
int r = n - k + 1;
// cout << COM(1998, 1) * COM(2, 2) << endl;
// cout << COM(1998, 2) * COM(2, 1) << endl;
// cout << COM(1998, 3) * COM(2, 0) << endl;
for (int i = 1; i <= k; ++i) {
cout << COM(r, i) * COM(k - 1, i - 1) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
int r = n - k + 1;
// cout << COM(1998, 1) * COM(2, 2) << endl;
// cout << COM(1998, 2) * COM(2, 1) << endl;
// cout << COM(1998, 3) * COM(2, 0) << endl;
for (int i = 1; i <= k; ++i) {
cout << COM(r, i) * COM(k - 1, i - 1) % MOD << endl;
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,287 | 797,289 | u189867560 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long nck(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
cominit();
vector<ll> ans;
for (int i = 1; i <= k; i++) {
ans.push_back(nck(k - 1, i - 1) * nck(n - k + 1, i));
}
for (auto t : ans) {
cout << t << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long nck(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
cominit();
vector<ll> ans;
for (int i = 1; i <= k; i++) {
ans.push_back(nck(k - 1, i - 1) * nck(n - k + 1, i) % MOD);
}
for (auto t : ans) {
cout << t << endl;
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,290 | 797,291 | u989306199 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < n; j++) {
for (size_t k = 0; k < n; k++) {
dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
}
}
}
}
class UnionFind {
public:
vector<ll> Parent;
UnionFind(ll N) { Parent = vector<ll>(N, -1); }
ll find(ll A) {
if (Parent[A] < 0)
return A;
return Parent[A] = find(Parent[A]);
}
ll size(ll A) { return -Parent[find(A)]; }
bool Union(ll A, ll B) {
A = find(A);
B = find(B);
if (A == B) {
return false;
}
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
ll mulMod(ll a, ll b) { return (((a % MOD) * (b % MOD)) % MOD); }
ll powMod(ll a, ll p) {
if (p == 0) {
return 1;
} else if (p % 2 == 0) {
ll half = powMod(a, p / 2);
return mulMod(half, half);
} else {
return mulMod(powMod(a, p - 1), a);
}
}
ll ceil(ll a, ll b) { return (a + b - 1) / b; }
std::vector<std::vector<long long>> comb(int n, int r) {
std::vector<std::vector<long long>> v(n + 1,
std::vector<long long>(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}
void solve(long long N, long long K) {
vector<vector<ll>> combination = comb(2010, 2010);
for (int i = 1; i <= K; i++) {
int balls = N - K + i;
int sukima = N - K + 1;
cout << combination[sukima][i] * combination[K - 1][i - 1] % MOD << endl;
}
}
int main() {
long long N;
scanf("%lld", &N);
long long K;
scanf("%lld", &K);
solve(N, K);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n) {
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < n; j++) {
for (size_t k = 0; k < n; k++) {
dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
}
}
}
}
class UnionFind {
public:
vector<ll> Parent;
UnionFind(ll N) { Parent = vector<ll>(N, -1); }
ll find(ll A) {
if (Parent[A] < 0)
return A;
return Parent[A] = find(Parent[A]);
}
ll size(ll A) { return -Parent[find(A)]; }
bool Union(ll A, ll B) {
A = find(A);
B = find(B);
if (A == B) {
return false;
}
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
};
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
ll mulMod(ll a, ll b) { return (((a % MOD) * (b % MOD)) % MOD); }
ll powMod(ll a, ll p) {
if (p == 0) {
return 1;
} else if (p % 2 == 0) {
ll half = powMod(a, p / 2);
return mulMod(half, half);
} else {
return mulMod(powMod(a, p - 1), a);
}
}
ll ceil(ll a, ll b) { return (a + b - 1) / b; }
std::vector<std::vector<long long>> comb(int n, int r) {
std::vector<std::vector<long long>> v(n + 1,
std::vector<long long>(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % MOD;
}
}
return v;
}
void solve(long long N, long long K) {
vector<vector<ll>> combination = comb(2010, 2010);
for (int i = 1; i <= K; i++) {
int balls = N - K + i;
int sukima = N - K + 1;
cout << combination[sukima][i] * combination[K - 1][i - 1] % MOD << endl;
}
}
int main() {
long long N;
scanf("%lld", &N);
long long K;
scanf("%lld", &K);
solve(N, K);
return 0;
}
| [
"assignment.change"
] | 797,292 | 797,293 | u228295160 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// 二分累乗法による a^b mod p
ll mod_pow(ll a, ll b, ll p) {
ll res = 1;
while (b > 0) {
if (b & 1)
res = res * a % p;
a = a * a % p;
b >>= 1;
}
return res;
}
vector<ll> fact;
// n! mod p
void mod_fact(ll n, ll p) {
fact.resize(n + 1);
fact[0] = 1;
for (int i = 1; i <= n; i++)
fact[i] = fact[i - 1] * i % p;
}
// nCk mod p
ll mod_comb(ll n, ll k, ll p) {
if (k > n)
return 0;
return fact[n] * mod_pow(fact[k] * fact[n - k] % p, p - 2, p) % p;
}
int main() {
ll n, k;
cin >> n >> k;
mod_fact(n, MOD);
for (int i = 1; i <= k; i++) {
ll ans = mod_comb(n - k + 1, i, MOD) * mod_comb(k - 1, i - 1, MOD);
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// 二分累乗法による a^b mod p
ll mod_pow(ll a, ll b, ll p) {
ll res = 1;
while (b > 0) {
if (b & 1)
res = res * a % p;
a = a * a % p;
b >>= 1;
}
return res;
}
vector<ll> fact;
// n! mod p
void mod_fact(ll n, ll p) {
fact.resize(n + 1);
fact[0] = 1;
for (int i = 1; i <= n; i++)
fact[i] = fact[i - 1] * i % p;
}
// nCk mod p
ll mod_comb(ll n, ll k, ll p) {
if (k > n)
return 0;
return fact[n] * mod_pow(fact[k] * fact[n - k] % p, p - 2, p) % p;
}
int main() {
ll n, k;
cin >> n >> k;
mod_fact(n, MOD);
for (int i = 1; i <= k; i++) {
ll ans = mod_comb(n - k + 1, i, MOD) * mod_comb(k - 1, i - 1, MOD) % MOD;
cout << ans << endl;
}
return 0;
}
| [
"assignment.change"
] | 797,296 | 797,297 | u705561278 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 1; i <= n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAX = 1e9 + 7;
ll fact[10003];
template <typename T> void factorial(T m) {
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i <= 10000; ++i) {
fact[i] = fact[i - 1] * i % m;
}
}
template <typename T> T Pow(T x, T n, T m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Pow(x * x % m, n / 2, m);
else
return x * Pow(x, n - 1, m) % m;
}
template <typename T> T combination(T n, T k, T m) {
return fact[n] * Pow<T>(fact[k], m - 2, m) % m *
Pow<T>(fact[n - k], m - 2, m) % m;
}
int main() {
ll n, k;
cin >> n >> k;
factorial<ll>(MOD);
REP(i, k) {
if (n - k + 1 >= 1) {
cout << combination<ll>(n - k + 1, i, MOD) *
combination<ll>(k - 1, i - 1, MOD) % MOD
<< endl;
} else
cout << 0 << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 1; i <= n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAX = 1e9 + 7;
ll fact[10003];
template <typename T> void factorial(T m) {
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i <= 10000; ++i) {
fact[i] = fact[i - 1] * i % m;
}
}
template <typename T> T Pow(T x, T n, T m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Pow(x * x % m, n / 2, m);
else
return x * Pow(x, n - 1, m) % m;
}
template <typename T> T combination(T n, T k, T m) {
return fact[n] * Pow<T>(fact[k], m - 2, m) % m *
Pow<T>(fact[n - k], m - 2, m) % m;
}
int main() {
ll n, k;
cin >> n >> k;
factorial<ll>(MOD);
REP(i, k) {
if (n - k + 1 >= i) {
cout << combination<ll>(n - k + 1, i, MOD) *
combination<ll>(k - 1, i - 1, MOD) % MOD
<< endl;
} else
cout << 0 << endl;
}
return 0;
} | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change"
] | 797,298 | 797,299 | u142577570 | cpp |
p02990 | #include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const ll MAX = 51000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
ll extGCD(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll d = extGCD(a, b % a, y, x);
y -= (a / b) * x;
return d;
}
void COMtable() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[n - k] * finv[k] % MOD) % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
ll a[K] = {0};
ll amari = N - K;
COMtable();
for (ll i = 0; i < K; i++) {
a[i] = COM(amari + 1, i + 1) * COM(K - 1, i);
}
for (ll i = 0; i < K; i++)
cout << a[i] << endl;
}
| #include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const ll MAX = 51000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
ll extGCD(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll d = extGCD(a, b % a, y, x);
y -= (a / b) * x;
return d;
}
void COMtable() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[n - k] * finv[k] % MOD) % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
ll a[K] = {0};
ll amari = N - K;
COMtable();
for (ll i = 0; i < K; i++) {
a[i] = COM(amari + 1, i + 1) * COM(K - 1, i) % MOD;
}
for (ll i = 0; i < K; i++)
cout << a[i] << endl;
}
| [
"assignment.change"
] | 797,300 | 797,301 | u255112547 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll LongINF = 1e13 + 7;
const int INF = 1e9 + 7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T, class Y> T GCD(T a, Y b) {
if (a < b) {
int c = a;
a = b;
b = c;
}
if (a % b == 0) {
return b;
}
return GCD(b, a % b);
}
template <class T, class Y> T LCM(T a, Y b) { return (a * b) / GCD(a, b); }
void clear(queue<pair<int, int>> &q) {
queue<pair<int, int>> empty;
swap(q, empty);
} // queueの中身の型は適時変更を忘れない
using vi = vector<int>;
using vii = vector<vi>;
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(), (a).end()
#define decimal(x) fixed << setprecision(x)
int main() {
int N, K;
cin >> N >> K;
vector<vector<ll>> C(2001, vector<ll>(2001, 0));
C[0][0] = 1;
rep(i, N + 1) {
rep(j, i + 1) {
if (i - 1 < 0)
continue;
if (j - 1 < 0)
C[i][j] = 1;
else
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
// cout<<C[i][j]<<" ";
}
// cout<<endl;
}
REP(i, 1, K + 1) {
cout << (C[N - K + 1][i] * C[K - 1][i - 1]) % INF << endl;
}
return 0;
}
// a=97,z=122 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll LongINF = 1e13 + 7;
const ll INF = 1e9 + 7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T, class Y> T GCD(T a, Y b) {
if (a < b) {
int c = a;
a = b;
b = c;
}
if (a % b == 0) {
return b;
}
return GCD(b, a % b);
}
template <class T, class Y> T LCM(T a, Y b) { return (a * b) / GCD(a, b); }
void clear(queue<pair<int, int>> &q) {
queue<pair<int, int>> empty;
swap(q, empty);
} // queueの中身の型は適時変更を忘れない
using vi = vector<int>;
using vii = vector<vi>;
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(), (a).end()
#define decimal(x) fixed << setprecision(x)
int main() {
ll N, K;
cin >> N >> K;
vector<vector<ll>> C(2001, vector<ll>(2001, 0));
C[0][0] = 1;
rep(i, N + 1) {
rep(j, i + 1) {
if (i - 1 < 0)
continue;
if (j - 1 < 0)
C[i][j] = 1;
else
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % INF;
// cout<<C[i][j]<<" ";
}
// cout<<endl;
}
REP(i, 1, K + 1) {
cout << (C[N - K + 1][i] * C[K - 1][i - 1]) % INF << endl;
}
return 0;
}
// a=97,z=122 | [
"variable_declaration.type.change",
"assignment.change"
] | 797,302 | 797,303 | u534015096 | cpp |
p02990 | #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long
using namespace std;
const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;
const int maxN = 1e4 + 1;
int fact[maxN], rev[maxN];
int mod_pow(int a, int b) {
if (!b)
return 1;
if (b % 2)
return a * mod_pow(a, b - 1) % MOD;
int q = mod_pow(a, b / 2);
return q * q % MOD;
}
int C(int n, int k) {
if (k > n)
return 0;
return (fact[n] * rev[k] % MOD) * rev[n - k] % MOD;
}
void solve() {
fact[0] = 1;
for (int i = 1; i < maxN; i++)
fact[i] = fact[i - 1] * i % MOD;
for (int i = 0; i < maxN; i++)
rev[i] = mod_pow(fact[i], MOD - 2);
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
int res = C(k - 1, i - 1);
int q = 0;
if (i > 1)
q = (q + res * C(n - k - 1, i - 2) % MOD) % MOD;
q = (q + res * C(n - k - 1, i - 1) * 2 % MOD) % MOD;
q = (q + res * C(n - k - 1, i) % MOD) % MOD;
if (i == n)
q++;
cout << q << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed;
cout.precision(12);
solve();
} | #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long
using namespace std;
const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;
const int maxN = 1e4 + 1;
int fact[maxN], rev[maxN];
int mod_pow(int a, int b) {
if (!b)
return 1;
if (b % 2)
return a * mod_pow(a, b - 1) % MOD;
int q = mod_pow(a, b / 2);
return q * q % MOD;
}
int C(int n, int k) {
if (k > n)
return 0;
return (fact[n] * rev[k] % MOD) * rev[n - k] % MOD;
}
void solve() {
fact[0] = 1;
for (int i = 1; i < maxN; i++)
fact[i] = fact[i - 1] * i % MOD;
for (int i = 0; i < maxN; i++)
rev[i] = mod_pow(fact[i], MOD - 2);
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
int res = C(k - 1, i - 1);
int q = 0;
if (i > 1)
q = (q + res * C(n - k - 1, i - 2) % MOD) % MOD;
q = (q + res * C(n - k - 1, i - 1) * 2 % MOD) % MOD;
q = (q + res * C(n - k - 1, i) % MOD) % MOD;
if (i == 1 && n == k)
q++;
cout << q << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed;
cout.precision(12);
solve();
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 797,309 | 797,310 | u782387599 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 4005;
const int mod = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
COMinit();
int i, N, K;
long long int ans;
cin >> N >> K;
for (i = 1; i < K + 1; i++) {
ans = (COM(K - 1, i - 1) * COM(N - K + 1, i + 1)) % mod;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
const int MAX = 4005;
const int mod = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
COMinit();
int i, N, K;
long long int ans;
cin >> N >> K;
for (i = 1; i < K + 1; i++) {
ans = (COM(K - 1, i - 1) * COM(N - K + 1, i)) % mod;
cout << ans << endl;
}
} | [
"expression.operation.binary.remove"
] | 797,317 | 797,318 | u983681697 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) \
{ std::cout << #a << " = " << a << "\n"; }
template <class T1, class T2> inline bool minimize(T1 &a, T2 b) {
return b < a && (a = b, 1);
}
template <class T1, class T2> inline bool maximize(T1 &a, T2 b) {
return a < b && (a = b, 1);
}
template <class T, class V> istream &operator>>(istream &ist, pair<T, V> &p) {
return ist >> p.first >> p.second;
}
template <class T> ostream &operator<<(ostream &ost, pair<T, T> &p) {
return ost << p.first << ", " << p.second;
}
template <class T> istream &operator>>(istream &ist, vector<T> &vs) {
for (auto &e : vs)
ist >> e;
return ist;
}
typedef long long ll;
int const inf = INT_MAX / 2;
int const MOD = 1e9 + 7;
namespace math {
constexpr int MaxComb = 2002;
struct Combination {
long long comb_[MaxComb][MaxComb];
Combination() {
rep(i, MaxComb) {
comb_[i][0] = 1;
REP(j, 1, i + 1) {
comb_[i][j] = comb_[i - 1][j - 1] + comb_[i - 1][j];
comb_[i][j] %= MOD;
}
}
}
long long comb(int n, int r) const { return comb_[n][r]; }
};
} // namespace math
math::Combination comb;
int main() {
int N, K;
cin >> N >> K;
REP(n_blue_group, 1, K + 1) {
ll pat = comb.comb(N - K + 1, n_blue_group);
pat *= comb.comb(K - 1, n_blue_group - 1) % MOD;
cout << pat << "\n";
}
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) \
{ std::cout << #a << " = " << a << "\n"; }
template <class T1, class T2> inline bool minimize(T1 &a, T2 b) {
return b < a && (a = b, 1);
}
template <class T1, class T2> inline bool maximize(T1 &a, T2 b) {
return a < b && (a = b, 1);
}
template <class T, class V> istream &operator>>(istream &ist, pair<T, V> &p) {
return ist >> p.first >> p.second;
}
template <class T> ostream &operator<<(ostream &ost, pair<T, T> &p) {
return ost << p.first << ", " << p.second;
}
template <class T> istream &operator>>(istream &ist, vector<T> &vs) {
for (auto &e : vs)
ist >> e;
return ist;
}
typedef long long ll;
int const inf = INT_MAX / 2;
int const MOD = 1e9 + 7;
namespace math {
constexpr int MaxComb = 2010;
struct Combination {
long long comb_[MaxComb][MaxComb];
Combination() {
rep(i, MaxComb) {
comb_[i][0] = 1;
REP(j, 1, i + 1) {
comb_[i][j] = comb_[i - 1][j - 1] + comb_[i - 1][j];
comb_[i][j] %= MOD;
}
}
}
long long comb(int n, int r) const { return comb_[n][r]; }
};
} // namespace math
math::Combination comb;
int main() {
int N, K;
cin >> N >> K;
REP(n_blue_group, 1, K + 1) {
ll pat = comb.comb(N - K + 1, n_blue_group);
(pat *= comb.comb(K - 1, n_blue_group - 1)) %= MOD;
cout << pat << "\n";
}
} | [
"literal.number.change",
"variable_declaration.value.change",
"assignment.variable.change",
"expression.operation.binary.change"
] | 797,319 | 797,320 | u809665051 | cpp |
p02990 | #include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pa;
const int N = 2e5 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int modd = 1e9 + 5;
ll a[2010];
void jc() {
a[0] = a[1] = 1;
for (int i = 2; i <= 2000; i++)
a[i] = a[i - 1] * i % mod;
}
ll ksm(ll x, ll y) {
if (x == 0)
return 0;
ll sum = 1;
while (y) {
if (y & 1)
sum = sum * x % mod;
x = x * x % mod;
y >>= 1;
}
return sum;
}
long long C(int n, int m) {
if (m > n)
return 0;
if (m == n)
return 1;
ll result;
result = (a[n] * ksm(a[n - m], modd) % mod) * ksm(a[m], modd);
return result;
}
int main() {
int n, k;
jc();
scanf("%d%d", &n, &k);
for (int i = 1; i <= k; i++) {
// ll ans1=(a[k-1]*ksm(a[i-1],modd)%mod)*ksm(a[k-i-1],modd)%mod;
// ll ans2=(a[n-k+1]*ksm(a[i],modd)%mod)*ksm(n-k+1-i,modd)%mod;
// ans1=ans1*ans2%mod;
ll ans = C(n - k + 1, i) * C(k - 1, i - 1) % mod;
printf("%lld\n", ans);
}
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pa;
const int N = 2e5 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int modd = 1e9 + 5;
ll a[2010];
void jc() {
a[0] = a[1] = 1;
for (int i = 2; i <= 2000; i++)
a[i] = a[i - 1] * i % mod;
}
ll ksm(ll x, ll y) {
if (x == 0)
return 0;
ll sum = 1;
while (y) {
if (y & 1)
sum = sum * x % mod;
x = x * x % mod;
y >>= 1;
}
return sum;
}
long long C(int n, int m) {
if (m > n)
return 0;
if (m == n)
return 1;
ll result;
result = (a[n] * ksm(a[n - m], modd) % mod) * ksm(a[m], modd) % mod;
return result;
}
int main() {
int n, k;
jc();
scanf("%d%d", &n, &k);
for (int i = 1; i <= k; i++) {
// ll ans1=(a[k-1]*ksm(a[i-1],modd)%mod)*ksm(a[k-i-1],modd)%mod;
// ll ans2=(a[n-k+1]*ksm(a[i],modd)%mod)*ksm(n-k+1-i,modd)%mod;
// ans1=ans1*ans2%mod;
ll ans = C(n - k + 1, i) * C(k - 1, i - 1) % mod;
printf("%lld\n", ans);
}
return 0;
}
| [
"assignment.change"
] | 797,321 | 797,322 | u722928342 | cpp |
p02990 | #include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pa;
const int N = 2e5 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int modd = 1e9 + 5;
ll a[2010];
void jc() {
a[0] = a[1] = 1;
for (int i = 2; i <= 2000; i++)
a[i] = a[i - 1] * i % mod;
}
ll ksm(ll x, ll y) {
if (x == 0)
return 0;
ll sum = 1;
while (y) {
if (y & 1)
sum = sum * x % mod;
x = x * x % mod;
y >>= 1;
}
return sum;
}
long long C(int n, int m) {
if (m > n)
return 0;
if (m == n)
return 1;
ll result;
result = a[n] * ksm(a[n - m], modd) % mod * ksm(a[m], modd);
return result;
}
int main() {
int n, k;
jc();
scanf("%d%d", &n, &k);
for (int i = 1; i <= k; i++) {
// ll ans1=(a[k-1]*ksm(a[i-1],modd)%mod)*ksm(a[k-i-1],modd)%mod;
// ll ans2=(a[n-k+1]*ksm(a[i],modd)%mod)*ksm(n-k+1-i,modd)%mod;
// ans1=ans1*ans2%mod;
ll ans = C(n - k + 1, i) * C(k - 1, i - 1) % mod;
printf("%lld\n", ans);
}
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pa;
const int N = 2e5 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int modd = 1e9 + 5;
ll a[2010];
void jc() {
a[0] = a[1] = 1;
for (int i = 2; i <= 2000; i++)
a[i] = a[i - 1] * i % mod;
}
ll ksm(ll x, ll y) {
if (x == 0)
return 0;
ll sum = 1;
while (y) {
if (y & 1)
sum = sum * x % mod;
x = x * x % mod;
y >>= 1;
}
return sum;
}
long long C(int n, int m) {
if (m > n)
return 0;
if (m == n)
return 1;
ll result;
result = (a[n] * ksm(a[n - m], modd) % mod) * ksm(a[m], modd) % mod;
return result;
}
int main() {
int n, k;
jc();
scanf("%d%d", &n, &k);
for (int i = 1; i <= k; i++) {
// ll ans1=(a[k-1]*ksm(a[i-1],modd)%mod)*ksm(a[k-i-1],modd)%mod;
// ll ans2=(a[n-k+1]*ksm(a[i],modd)%mod)*ksm(n-k+1-i,modd)%mod;
// ans1=ans1*ans2%mod;
ll ans = C(n - k + 1, i) * C(k - 1, i - 1) % mod;
printf("%lld\n", ans);
}
return 0;
}
| [
"assignment.change"
] | 797,323 | 797,322 | u722928342 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vvl memo(2001, vl(2001, -1));
ll choose(ll x, ll y) {
if (memo[x][y] != -1) {
return memo[x][y];
} else {
if (x < 0 || y < 0) {
return 0;
} else if (x < y) {
memo[x][y] = 0;
return 0;
} else if (y == 0) {
memo[x][y] = 1;
return memo[x][y];
} else if (x == y) {
memo[x][y] = 1;
return 1;
} else {
memo[x][y] = choose(x - 1, y - 1) + choose(x - 1, y);
return memo[x][y];
}
}
}
int main() {
ll n, k;
cin >> n >> k;
FOR(i, 1, k + 1) {
cout << choose(n - k + 1, i) * choose(k - 1, i - 1) % MOD << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vvl memo(2001, vl(2001, -1));
ll choose(ll x, ll y) {
if (memo[x][y] != -1) {
return memo[x][y];
} else {
if (x < 0 || y < 0) {
return 0;
} else if (x < y) {
memo[x][y] = 0;
return 0;
} else if (y == 0) {
memo[x][y] = 1;
return memo[x][y];
} else if (x == y) {
memo[x][y] = 1;
return 1;
} else {
memo[x][y] = (choose(x - 1, y - 1) + choose(x - 1, y)) % MOD;
return memo[x][y];
}
}
}
int main() {
ll n, k;
cin >> n >> k;
FOR(i, 1, k + 1) {
cout << choose(n - k + 1, i) * choose(k - 1, i - 1) % MOD << endl;
}
} | [
"assignment.change"
] | 797,326 | 797,327 | u328811800 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < (int)(n); i++)
ll MOD = 1000000007;
ll pow_mod(ll x, ll n) {
x %= MOD;
if (n == 0)
return 1;
else if (n % 2 == 1)
return (x * pow_mod(x, n - 1)) % MOD;
else
return pow_mod((x * x) % MOD, n / 2) % MOD;
}
ll comb(ll l, ll m) {
if (l < m)
return 0;
ll t1 = 1, t2 = 1;
for (ll i = l; i >= l - m + 1; i--)
t1 = t1 * i % MOD;
for (ll i = 1; i <= m; i++)
t2 = t2 * i % MOD;
t2 = pow_mod(t2, MOD - 2);
return t1 * t2 % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 1; i < K + 1; i++)
cout << comb(K - 1, i - 1) * comb(N - K + 1, i) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < (int)(n); i++)
ll MOD = 1000000007;
ll pow_mod(ll x, ll n) {
x %= MOD;
if (n == 0)
return 1;
else if (n % 2 == 1)
return (x * pow_mod(x, n - 1)) % MOD;
else
return pow_mod((x * x) % MOD, n / 2) % MOD;
}
ll comb(ll l, ll m) {
if (l < m)
return 0;
ll t1 = 1, t2 = 1;
for (ll i = l; i >= l - m + 1; i--)
t1 = t1 * i % MOD;
for (ll i = 1; i <= m; i++)
t2 = t2 * i % MOD;
t2 = pow_mod(t2, MOD - 2);
return t1 * t2 % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 1; i < K + 1; i++)
cout << comb(K - 1, i - 1) * comb(N - K + 1, i) % MOD << endl;
}
| [
"expression.operation.binary.add"
] | 797,328 | 797,329 | u433189059 | cpp |
p02990 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
using namespace std;
using Graph = vector<vector<Int>>;
const double pi = M_PI;
const Int MOD = 1000000007;
Int modpow(Int a, Int n, Int mod) {
Int ret = 1;
while (n > 0) {
if (n & 1) {
ret = ret * a % mod;
}
a = a * a % mod;
n >>= 1;
}
return ret;
}
vector<Int> factorials(0), invs(0);
bool is_ncr_table = false;
void calc_ncr_table(Int n, Int mod) {
is_ncr_table = true;
// 1! ~ n! の計算
Int f = 1;
factorials.push_back(f);
for (Int i = 1; i < n + 1; i++) {
f *= i;
f %= mod;
factorials.push_back(f);
}
// n!^-1 の計算
Int inv = modpow(factorials[n], mod - 2, mod);
// (n-1)!^-1 ~ 1!^-1 の計算
invs.assign(n, 1);
invs[n] = inv;
for (Int i = n; i >= 1; i--) {
inv *= i;
inv %= mod;
invs[i - 1] = inv;
}
}
Int factorial(Int n, Int mod = 1) {
Int ret = 1;
if (mod == 1) {
for (Int i = 1; i < n + 1; i++) {
ret *= i;
}
return ret;
} else {
for (Int i = 1; i < n + 1; i++) {
ret *= i;
ret %= mod;
}
return ret;
}
}
Int ncr(Int n, Int r, Int mod, bool use_table = false) {
if (n < r) {
return (Int)0;
} else {
if (use_table) {
// modが素数の場合のみ
if (!is_ncr_table) {
calc_ncr_table(n, mod);
}
return (factorials[n] * invs[r] % mod) * invs[n - r] % mod;
} else {
Int x = 1;
for (Int i = n - r + 1; i < n + 1; i++) {
x *= i;
x %= mod;
}
return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
}
}
}
int main() {
Int n, k;
cin >> n >> k;
calc_ncr_table(n, MOD);
vector<Int> rr(k);
for (Int i = 0; i <= k - 1; i++) {
rr[i] = ncr(k - 1, i, MOD, true) % MOD;
}
for (Int i = 1; i <= k; i++) {
Int ans = 0;
Int nn = n - k + 1;
ans += ncr(nn, i, MOD, true);
ans *= rr[i - 1] % MOD;
ans %= MOD;
cout << ans << endl;
}
return 0;
} | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
using namespace std;
using Graph = vector<vector<Int>>;
const double pi = M_PI;
const Int MOD = 1000000007;
Int modpow(Int a, Int n, Int mod) {
Int ret = 1;
while (n > 0) {
if (n & 1) {
ret = ret * a % mod;
}
a = a * a % mod;
n >>= 1;
}
return ret;
}
vector<Int> factorials(0), invs(0);
bool is_ncr_table = false;
void calc_ncr_table(Int n, Int mod) {
is_ncr_table = true;
// 1! ~ n! の計算
Int f = 1;
factorials.push_back(f);
for (Int i = 1; i < n + 1; i++) {
f *= i;
f %= mod;
factorials.push_back(f);
}
// n!^-1 の計算
Int inv = modpow(factorials[n], mod - 2, mod);
// (n-1)!^-1 ~ 1!^-1 の計算
invs.assign(n, 1);
invs[n] = inv;
for (Int i = n; i >= 1; i--) {
inv *= i;
inv %= mod;
invs[i - 1] = inv;
}
}
Int factorial(Int n, Int mod = 1) {
Int ret = 1;
if (mod == 1) {
for (Int i = 1; i < n + 1; i++) {
ret *= i;
}
return ret;
} else {
for (Int i = 1; i < n + 1; i++) {
ret *= i;
ret %= mod;
}
return ret;
}
}
Int ncr(Int n, Int r, Int mod, bool use_table = false) {
if (n < r) {
return (Int)0;
} else {
if (use_table) {
// modが素数の場合のみ
if (!is_ncr_table) {
calc_ncr_table(n, mod);
}
return (factorials[n] * invs[r] % mod) * invs[n - r] % mod;
} else {
Int x = 1;
for (Int i = n - r + 1; i < n + 1; i++) {
x *= i;
x %= mod;
}
return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
}
}
}
int main() {
Int n, k;
cin >> n >> k;
calc_ncr_table(2010, MOD);
vector<Int> rr(k);
for (Int i = 0; i <= k - 1; i++) {
rr[i] = ncr(k - 1, i, MOD, true) % MOD;
}
for (Int i = 1; i <= k; i++) {
Int ans = 0;
Int nn = n - k + 1;
ans += ncr(nn, i, MOD, true);
ans *= rr[i - 1] % MOD;
ans %= MOD;
cout << ans << endl;
}
return 0;
} | [
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change"
] | 797,336 | 797,337 | u261538386 | cpp |
p02990 | #include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2010, mod = 1e9 + 7;
int n, k;
int f[N][N];
int main() {
cin >> n >> k;
for (int i = 0; i < N; i++)
f[i][0] = 1;
for (int i = 1; i < N; i++)
for (int j = 1; j <= i; j++)
f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % mod;
for (int i = 1; i <= k; i++)
cout << f[k - 1][i - 1] * f[n - k + 1][i] % mod << endl;
return 0;
} | #include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2010, mod = 1e9 + 7;
int n, k;
LL f[N][N];
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++)
f[i][0] = 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++)
f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % mod;
for (int i = 1; i <= k; i++)
cout << f[k - 1][i - 1] * f[n - k + 1][i] % mod << endl;
return 0;
} | [
"variable_declaration.type.change",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 797,338 | 797,339 | u866538547 | cpp |
p02990 | #include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2010, mod = 1e9 + 7;
int n, k;
int f[N][N];
int main() {
cin >> n >> k;
for (int i = 0; i <= n; i++)
f[i][0] = 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++)
f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % mod;
for (int i = 1; i <= k; i++)
cout << f[k - 1][i - 1] * f[n - k + 1][i] % mod << endl;
return 0;
} | #include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2010, mod = 1e9 + 7;
int n, k;
LL f[N][N];
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++)
f[i][0] = 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++)
f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % mod;
for (int i = 1; i <= k; i++)
cout << f[k - 1][i - 1] * f[n - k + 1][i] % mod << endl;
return 0;
} | [
"variable_declaration.type.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 797,340 | 797,339 | u866538547 | cpp |
p02990 | #include <iostream>
#include <vector>
std::vector<std::vector<unsigned long>> comb(unsigned long n, unsigned long r) {
std::vector<std::vector<unsigned long>> v(
n + 1, std::vector<unsigned long>(n + 1, 0));
for (unsigned long i = 0; i < v.size(); ++i) {
v[i][0] = 1;
v[i][i] = 1;
}
for (unsigned long i = 1; i < v.size(); ++i) {
for (unsigned long j = 1; j < i; ++j) {
v[i][j] = ((v[i - 1][j - 1] % 1000000007) + (v[i - 1][j] % 1000000007)) %
1000000007;
}
}
return v;
}
int main() {
unsigned long N, K;
std::cin >> N >> K;
const unsigned long max = std::max(K - 1, N - K + 1);
const std::vector<std::vector<unsigned long>> my_comb = comb(max, K);
for (unsigned long i = 1; i <= K; ++i) {
const unsigned long blue = my_comb[K - 1][i - 1];
const unsigned long red = my_comb[N - K + 1][i];
std::cout << ((blue % 1000000007) * (red % 1000000007)) % 1000000007
<< std::endl;
}
return 0;
}
| #include <iostream>
#include <vector>
std::vector<std::vector<unsigned long>> comb(unsigned long n, unsigned long r) {
std::vector<std::vector<unsigned long>> v(
n + 1, std::vector<unsigned long>(n + 1, 0));
for (unsigned long i = 0; i < v.size(); ++i) {
v[i][0] = 1;
v[i][i] = 1;
}
for (unsigned long i = 1; i < v.size(); ++i) {
for (unsigned long j = 1; j < i; ++j) {
v[i][j] = ((v[i - 1][j - 1] % 1000000007) + (v[i - 1][j] % 1000000007)) %
1000000007;
}
}
return v;
}
int main() {
unsigned long N, K;
std::cin >> N >> K;
const unsigned long max = std::max(K, N - K + 1);
const std::vector<std::vector<unsigned long>> my_comb = comb(max, K);
for (unsigned long i = 1; i <= K; ++i) {
const unsigned long blue = my_comb[K - 1][i - 1];
const unsigned long red = my_comb[N - K + 1][i];
std::cout << ((blue % 1000000007) * (red % 1000000007)) % 1000000007
<< std::endl;
}
return 0;
}
| [
"expression.operation.binary.remove"
] | 797,343 | 797,344 | u706001235 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 999999999
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1000000007;
ll cnt = 0;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理、これも呼ぶ
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算関数
long long comb(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; i++) {
cout << comb(n - k + 1, i) * comb(k - 1, i - 1) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 999999999
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1000000007;
ll cnt = 0;
const int MAX = 510000;
unsigned ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理、これも呼ぶ
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算関数
long long comb(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; i++) {
cout << comb(n - k + 1, i) * comb(k - 1, i - 1) % MOD << endl;
}
} | [
"expression.operation.binary.add"
] | 797,345 | 797,346 | u179593519 | cpp |
p02990 | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <typename T> T seinomi(T a) {
if (a > 0) {
return a;
} else {
return 0;
}
}
//連想配列[素因数f.first][個数f.second]
template <typename T> map<T, T> soinsuubunkai(T n) {
map<T, T> ret;
for (T i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
//桁数取得
template <typename T> T ketasuu(T num) { return std::to_string(num).length(); }
//階乗
ll kaizyou(ll k) {
ll sum = 1;
for (ll i = 1; i <= k; ++i) {
sum *= i;
}
return sum;
}
//階乗を(10^9)+7で割った余り
ll modkaizyou(ll k) {
ll sum = 1;
for (int i = 1; i <= k; ++i) {
sum *= i;
sum = sum % mod;
}
return sum;
}
template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value) {
while (first != last) {
*first++ = value;
++value;
}
}
//整数乗
int llpow(ll a, ll n) { // aのn乗を計算します。
ll x = 1;
while (n > 0) { //全てのbitが捨てられるまで。
if (n & 1) { // 1番右のbitが1のとき。
x = x * a;
}
a = a * a;
n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。
}
return x;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
template <typename T> T amarinasi(T a, T b) {
if (a % b == 0) {
return a / b;
} else if (a % b > 0) {
return a / b + 1;
} else {
return a / b - 1;
}
}
//組み合わせ nCr
vector<vector<ll>> nCr_v(5010, vector<ll>(5010, 0));
bool nCr_maekeisan = false;
void nCr_Calculater() {
for (int i = 0; i < nCr_v.size(); i++) {
nCr_v[i][0] = 1;
nCr_v[i][i] = 1;
}
for (int k = 1; k < nCr_v.size(); k++) {
for (int j = 1; j < k; j++) {
nCr_v[k][j] = (nCr_v[k - 1][j - 1] + nCr_v[k - 1][j]);
}
}
}
ll nCr(ll n, ll r) {
if (nCr_maekeisan == false) {
nCr_Calculater();
nCr_maekeisan = true;
}
return nCr_v[n][r];
}
// 組み合わせnCrを1000000007で割った余り
vector<ll> modnCr_fac(1000010), modnCr_finv(1000010), modnCr_inv(1000010);
bool modnCr_maekeisan = false;
void COMinit() {
modnCr_fac[0] = modnCr_fac[1] = 1;
modnCr_finv[0] = modnCr_finv[1] = 1;
modnCr_inv[1] = 1;
for (int i = 2; i < 1000010; i++) {
modnCr_fac[i] = modnCr_fac[i - 1] * i % mod;
modnCr_inv[i] = mod - modnCr_inv[mod % i] * (mod / i) % mod;
modnCr_finv[i] = modnCr_finv[i - 1] * modnCr_inv[i] % mod;
}
}
ll COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return modnCr_fac[n] * (modnCr_finv[k] * modnCr_finv[n - k] % mod) % mod;
}
ll modnCr(ll n, ll r) {
if (modnCr_maekeisan == false) {
COMinit();
modnCr_maekeisan = true;
}
return COM(n, r);
}
//順列 nPr
ll nPr(ll n, ll r) {
r = n - r;
ll sum = 1;
ll i;
for (i = n; i >= r + 1; i--)
sum *= i;
return sum;
}
//重複組み合わせ nHr = (r+n-1)Cr
ll nHr(ll n, ll r) { return modnCr(r + n - 1, r); }
//弧度法から度数法に変換
double to_deg(double r) { return r * 180.0 / (atan(1.0) * 4.0); }
//座標から度数法の角度に変換
double kakudo(double dx, double dy) {
return atan2(dx, dy) * 180.0 / (atan(1.0) * 4.0);
}
//約数列挙配列(1を必ず含むことに注意)
vector<ll> yakusuu(ll n) {
vector<ll> ret;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
//素数判定bool型配列
std::vector<bool> sosuuhantei(ll max) {
vector<bool> ret;
if (max + 1 > ret.size()) { // resizeで要素数が減らないように
ret.resize(max + 1, true); // IsPrimeに必要な要素数を確保
}
ret[0] = false; // 0は素数ではない
ret[1] = false; // 1は素数ではない
for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる
if (ret[i]) { // iが素数ならば
for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は
ret[i * j] = false; // 素数ではない
}
}
}
return (ret);
}
//素数列挙longlong型配列
std::vector<ll> sosuurekkyo(ll max) {
vector<bool> tmp;
vector<ll> ret;
if (max + 1 > tmp.size()) { // resizeで要素数が減らないように
tmp.resize(max + 1, true); // IsPrimeに必要な要素数を確保
}
tmp[0] = false; // 0は素数ではない
tmp[1] = false; // 1は素数ではない
for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる
if (tmp[i]) { // iが素数ならば
for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は
tmp[i * j] = false; // 素数ではない
}
}
}
for (ll i = 0; i <= max; i++) {
if (tmp[i]) {
ret.push_back(i);
}
}
return (ret);
}
//小数点以下10桁テンプレート(main関数内の最初に貼付け)
// std::cout << std::fixed << std::setprecision(10);
//----------------------------------------------------------------
int main() {
ll n, k;
cin >> n >> k;
ll red = n - k;
for (ll i = 1; i <= k; i++) {
ll tmp1 = nCr(red + 1, i);
ll tmp2 = nCr(k - 1, i - 1);
cout << (tmp1 * tmp2) % mod << endl;
}
} | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <typename T> T seinomi(T a) {
if (a > 0) {
return a;
} else {
return 0;
}
}
//連想配列[素因数f.first][個数f.second]
template <typename T> map<T, T> soinsuubunkai(T n) {
map<T, T> ret;
for (T i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
//桁数取得
template <typename T> T ketasuu(T num) { return std::to_string(num).length(); }
//階乗
ll kaizyou(ll k) {
ll sum = 1;
for (ll i = 1; i <= k; ++i) {
sum *= i;
}
return sum;
}
//階乗を(10^9)+7で割った余り
ll modkaizyou(ll k) {
ll sum = 1;
for (int i = 1; i <= k; ++i) {
sum *= i;
sum = sum % mod;
}
return sum;
}
template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value) {
while (first != last) {
*first++ = value;
++value;
}
}
//整数乗
int llpow(ll a, ll n) { // aのn乗を計算します。
ll x = 1;
while (n > 0) { //全てのbitが捨てられるまで。
if (n & 1) { // 1番右のbitが1のとき。
x = x * a;
}
a = a * a;
n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。
}
return x;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
template <typename T> T amarinasi(T a, T b) {
if (a % b == 0) {
return a / b;
} else if (a % b > 0) {
return a / b + 1;
} else {
return a / b - 1;
}
}
//組み合わせ nCr
vector<vector<ll>> nCr_v(5010, vector<ll>(5010, 0));
bool nCr_maekeisan = false;
void nCr_Calculater() {
for (int i = 0; i < nCr_v.size(); i++) {
nCr_v[i][0] = 1;
nCr_v[i][i] = 1;
}
for (int k = 1; k < nCr_v.size(); k++) {
for (int j = 1; j < k; j++) {
nCr_v[k][j] = (nCr_v[k - 1][j - 1] + nCr_v[k - 1][j]);
}
}
}
ll nCr(ll n, ll r) {
if (nCr_maekeisan == false) {
nCr_Calculater();
nCr_maekeisan = true;
}
return nCr_v[n][r];
}
// 組み合わせnCrを1000000007で割った余り
vector<ll> modnCr_fac(1000010), modnCr_finv(1000010), modnCr_inv(1000010);
bool modnCr_maekeisan = false;
void COMinit() {
modnCr_fac[0] = modnCr_fac[1] = 1;
modnCr_finv[0] = modnCr_finv[1] = 1;
modnCr_inv[1] = 1;
for (int i = 2; i < 1000010; i++) {
modnCr_fac[i] = modnCr_fac[i - 1] * i % mod;
modnCr_inv[i] = mod - modnCr_inv[mod % i] * (mod / i) % mod;
modnCr_finv[i] = modnCr_finv[i - 1] * modnCr_inv[i] % mod;
}
}
ll COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return modnCr_fac[n] * (modnCr_finv[k] * modnCr_finv[n - k] % mod) % mod;
}
ll modnCr(ll n, ll r) {
if (modnCr_maekeisan == false) {
COMinit();
modnCr_maekeisan = true;
}
return COM(n, r);
}
//順列 nPr
ll nPr(ll n, ll r) {
r = n - r;
ll sum = 1;
ll i;
for (i = n; i >= r + 1; i--)
sum *= i;
return sum;
}
//重複組み合わせ nHr = (r+n-1)Cr
ll nHr(ll n, ll r) { return modnCr(r + n - 1, r); }
//弧度法から度数法に変換
double to_deg(double r) { return r * 180.0 / (atan(1.0) * 4.0); }
//座標から度数法の角度に変換
double kakudo(double dx, double dy) {
return atan2(dx, dy) * 180.0 / (atan(1.0) * 4.0);
}
//約数列挙配列(1を必ず含むことに注意)
vector<ll> yakusuu(ll n) {
vector<ll> ret;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
//素数判定bool型配列
std::vector<bool> sosuuhantei(ll max) {
vector<bool> ret;
if (max + 1 > ret.size()) { // resizeで要素数が減らないように
ret.resize(max + 1, true); // IsPrimeに必要な要素数を確保
}
ret[0] = false; // 0は素数ではない
ret[1] = false; // 1は素数ではない
for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる
if (ret[i]) { // iが素数ならば
for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は
ret[i * j] = false; // 素数ではない
}
}
}
return (ret);
}
//素数列挙longlong型配列
std::vector<ll> sosuurekkyo(ll max) {
vector<bool> tmp;
vector<ll> ret;
if (max + 1 > tmp.size()) { // resizeで要素数が減らないように
tmp.resize(max + 1, true); // IsPrimeに必要な要素数を確保
}
tmp[0] = false; // 0は素数ではない
tmp[1] = false; // 1は素数ではない
for (ll i = 2; i * i <= max; ++i) { // 0からsqrt(max)まで調べる
if (tmp[i]) { // iが素数ならば
for (ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は
tmp[i * j] = false; // 素数ではない
}
}
}
for (ll i = 0; i <= max; i++) {
if (tmp[i]) {
ret.push_back(i);
}
}
return (ret);
}
//小数点以下10桁テンプレート(main関数内の最初に貼付け)
// std::cout << std::fixed << std::setprecision(10);
//----------------------------------------------------------------
int main() {
ll n, k;
cin >> n >> k;
ll red = n - k;
for (ll i = 1; i <= k; i++) {
ll tmp1 = modnCr(red + 1, i);
ll tmp2 = modnCr(k - 1, i - 1);
cout << (tmp1 * tmp2) % mod << endl;
}
} | [
"identifier.change",
"call.function.change"
] | 797,352 | 797,353 | u863537799 | cpp |
p02990 | #include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long
//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int, vector<int>> vvec;
typedef long double ld;
typedef pair<int, int> P;
//----***Like a Pythonista***----
#define REP(i, j, n) for (ll i = j; i < (n); i++)
#define RREP(i, n, j) for (ll i = n; j < i; i--)
#define each(i, ...) for (auto &&i : __VA_ARGS__)
#define ALL(vec) (vec).begin(), (vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__), 0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__), 0.0L)
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
template <class T> inline auto max(const T &a) { return *max_element(ALL(a)); }
template <class T> inline auto min(const T &a) { return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b) {
while (b) {
ll c = b;
b = a % b;
a = c;
}
return a;
}
inline ll lcm(ll a, ll b) {
if (!a || !b)
return 0;
return a * b / gcd(a, b);
}
//----***定数***----
const int MOD = 1e9 + 7;
#define INF 1e9;
#define EPS 1e-9;
//----***入出力***---
#define print(out) cout << out << "\n";
#define debug(var) \
do { \
std::cerr << #var << " ↓ " \
<< "\n"; \
view(var); \
} while (0)
template <typename T> void view(T e) { std::cout << e << std::endl; }
template <typename T> void view(const std::vector<T> &v) {
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void view(const std::vector<std::vector<T>> &vv) {
for (const auto &v : vv) {
view(v);
}
}
#define here cout << "Here" << endl;
//----***初期時読み込み***----
struct initial {
initial() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
};
} initial_;
signed main() {
int N, K;
cin >> N >> K;
vector<vector<int>> dp(N + 1, vector<int>(K + 1, 0));
dp[0][0] = 0;
REP(i, 0, N + 1) {
dp[i][0] = 1;
dp[i][1] = i;
}
REP(i, 1, N + 1) REP(j, 2, K + 1) {
dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
dp[i][j] %= MOD;
}
// debug(dp);
// print(dp[N-K+1][1]*(K-2));
REP(i, 1, K + 1) {
int ans = dp[N - K + 1][i] * dp[K - 1][i - 1];
print(ans)
}
}
| #include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long
//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int, vector<int>> vvec;
typedef long double ld;
typedef pair<int, int> P;
//----***Like a Pythonista***----
#define REP(i, j, n) for (ll i = j; i < (n); i++)
#define RREP(i, n, j) for (ll i = n; j < i; i--)
#define each(i, ...) for (auto &&i : __VA_ARGS__)
#define ALL(vec) (vec).begin(), (vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__), 0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__), 0.0L)
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
template <class T> inline auto max(const T &a) { return *max_element(ALL(a)); }
template <class T> inline auto min(const T &a) { return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b) {
while (b) {
ll c = b;
b = a % b;
a = c;
}
return a;
}
inline ll lcm(ll a, ll b) {
if (!a || !b)
return 0;
return a * b / gcd(a, b);
}
//----***定数***----
const int MOD = 1e9 + 7;
#define INF 1e9;
#define EPS 1e-9;
//----***入出力***---
#define print(out) cout << out << "\n";
#define debug(var) \
do { \
std::cerr << #var << " ↓ " \
<< "\n"; \
view(var); \
} while (0)
template <typename T> void view(T e) { std::cout << e << std::endl; }
template <typename T> void view(const std::vector<T> &v) {
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void view(const std::vector<std::vector<T>> &vv) {
for (const auto &v : vv) {
view(v);
}
}
#define here cout << "Here" << endl;
//----***初期時読み込み***----
struct initial {
initial() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
};
} initial_;
signed main() {
int N, K;
cin >> N >> K;
vector<vector<int>> dp(N + 1, vector<int>(K + 1, 0));
dp[0][0] = 0;
REP(i, 0, N + 1) {
dp[i][0] = 1;
dp[i][1] = i;
}
REP(i, 1, N + 1) REP(j, 2, K + 1) {
dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
dp[i][j] %= MOD;
}
// debug(dp);
// print(dp[N-K+1][1]*(K-2));
REP(i, 1, K + 1) {
int ans = dp[N - K + 1][i] * dp[K - 1][i - 1];
ans %= MOD;
print(ans)
}
}
| [
"assignment.add"
] | 797,356 | 797,357 | u526459074 | cpp |
p02990 | #include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18 + 1;
#define DIV 1000000007
ll PowMod(ll n, ll p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
ll t = PowMod(n, p / 2);
return t * t % DIV;
}
return n * PowMod(n, p - 1) % DIV;
}
ll comb(ll n, ll r) {
// 分母と分子。いい名前思いつかなかった
ll res, deno, mole;
res = deno = mole = 1;
for (ll i = 0; i < r; i++) {
mole *= (n - i);
mole %= DIV;
deno *= (r - i);
deno %= DIV;
}
// 分母の逆元
res = PowMod(deno, DIV - 2);
res = (res * mole) % DIV;
return res;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef TEST
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
#endif
long idx = 0;
long N, K;
cin >> N >> K;
long red = N - K;
for (size_t i = 1; i <= K; i++) {
if (min((long)K - i, (long)red - i + 1) < 0) {
cout << 0 << endl;
continue;
}
// 赤いボールの間 red+1 箇所から青いボールのまとまり i を置く場所を考える
// comb(red+1 , red-i+1) 青いボール、ボールとボールの間 K-1 個から i-1
// 個の場所を選択する方法 comb(K-1 , K-i)
cout << comb(K - 1, K - i) * comb(red + 1, red - i + 1) % DIV << endl;
}
#ifdef TEST
end = chrono::system_clock::now();
cerr << static_cast<double>(
chrono::duration_cast<chrono::microseconds>(end - start).count() /
1000.0)
<< "[ms]" << endl;
#endif
return 0;
} | #include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18 + 1;
#define DIV 1000000007
ll PowMod(ll n, ll p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
ll t = PowMod(n, p / 2);
return t * t % DIV;
}
return n * PowMod(n, p - 1) % DIV;
}
ll comb(ll n, ll r) {
// 分母と分子。いい名前思いつかなかった
ll res, deno, mole;
res = deno = mole = 1;
for (ll i = 0; i < r; i++) {
mole *= (n - i);
mole %= DIV;
deno *= (r - i);
deno %= DIV;
}
// 分母の逆元
res = PowMod(deno, DIV - 2);
res = (res * mole) % DIV;
return res;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef TEST
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
#endif
long idx = 0;
long N, K;
cin >> N >> K;
long red = N - K;
for (size_t i = 1; i <= K; i++) {
if (min((long)K - i, (long)red - i + 1) < 0) {
cout << 0 << endl;
continue;
}
// 赤いボールの間 red+1 箇所から青いボールのまとまり i を置く場所を考える
// comb(red+1 , red-i+1) 青いボール、ボールとボールの間 K-1 個から i-1
// 個の場所を選択する方法 comb(K-1 , K-i)
cout << comb(K - 1, K - i) * comb(red + 1, i) % DIV << endl;
}
#ifdef TEST
end = chrono::system_clock::now();
cerr << static_cast<double>(
chrono::duration_cast<chrono::microseconds>(end - start).count() /
1000.0)
<< "[ms]" << endl;
#endif
return 0;
} | [
"expression.operation.binary.remove"
] | 797,359 | 797,360 | u645961531 | cpp |
p02990 | #include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18 + 1;
#define DIV 1000000007
ll PowMod(ll n, ll p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
ll t = PowMod(n, p / 2);
return t * t % DIV;
}
return n * PowMod(n, p - 1) % DIV;
}
ll comb(ll n, ll r) {
// 分母と分子。いい名前思いつかなかった
ll res, deno, mole;
res = deno = mole = 1;
for (int i = 0; i < r; i++) {
mole *= (n - i);
mole %= DIV;
deno *= (r - i);
deno %= DIV;
}
// 分母の逆元
res = PowMod(deno, DIV - 2);
res = (res * mole) % DIV;
return res;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef TEST
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
#endif
long idx = 0;
long N, K;
cin >> N >> K;
long red = N - K;
for (size_t i = 1; i <= K; i++) {
if (min((long)K - i, (long)red - i + 1) < 0) {
cout << 0 << endl;
continue;
}
// 赤いボールの間 red+1 箇所から青いボールのまとまり i を置く場所を考える
// comb(red+1 , red-i+1) 青いボール、ボールとボールの間 K-1 個から i-1
// 個の場所を選択する方法 comb(K-1 , K-i)
cout << comb(K - 1, K - i) * comb(red + 1, red - i + 1) % DIV << endl;
}
#ifdef TEST
end = chrono::system_clock::now();
cerr << static_cast<double>(
chrono::duration_cast<chrono::microseconds>(end - start).count() /
1000.0)
<< "[ms]" << endl;
#endif
return 0;
} | #include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18 + 1;
#define DIV 1000000007
ll PowMod(ll n, ll p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
ll t = PowMod(n, p / 2);
return t * t % DIV;
}
return n * PowMod(n, p - 1) % DIV;
}
ll comb(ll n, ll r) {
// 分母と分子。いい名前思いつかなかった
ll res, deno, mole;
res = deno = mole = 1;
for (ll i = 0; i < r; i++) {
mole *= (n - i);
mole %= DIV;
deno *= (r - i);
deno %= DIV;
}
// 分母の逆元
res = PowMod(deno, DIV - 2);
res = (res * mole) % DIV;
return res;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef TEST
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
#endif
long idx = 0;
long N, K;
cin >> N >> K;
long red = N - K;
for (size_t i = 1; i <= K; i++) {
if (min((long)K - i, (long)red - i + 1) < 0) {
cout << 0 << endl;
continue;
}
// 赤いボールの間 red+1 箇所から青いボールのまとまり i を置く場所を考える
// comb(red+1 , red-i+1) 青いボール、ボールとボールの間 K-1 個から i-1
// 個の場所を選択する方法 comb(K-1 , K-i)
cout << comb(K - 1, K - i) * comb(red + 1, i) % DIV << endl;
}
#ifdef TEST
end = chrono::system_clock::now();
cerr << static_cast<double>(
chrono::duration_cast<chrono::microseconds>(end - start).count() /
1000.0)
<< "[ms]" << endl;
#endif
return 0;
} | [
"control_flow.loop.for.initializer.change",
"variable_declaration.type.change",
"expression.operation.binary.remove"
] | 797,361 | 797,360 | u645961531 | cpp |
p02990 | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9) + 7;
const ll inf = ll(5e18);
template <typename T1, typename T2> ll ceill(T1 a, T2 b) {
return (a + b - 1) / b;
}
void ans(bool b, ostream &out = cout) { out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream &out = cout) { out << (b ? "YES" : "NO") << endl; }
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP
#include <iostream>
#include <map>
#include <vector>
using namespace std;
namespace dbg {
using ll = long long;
class Debug {
public:
Debug() {}
template <typename T> void vd(vector<T> vec);
template <typename T> void vd2(vector<vector<T>> vec);
template <typename T> void ad(T *arr, ll n);
template <typename T, size_t N> void ad2(T (&arr)[N], ll n);
template <typename T> void md(T mp);
};
template <typename T> void Debug::vd(vector<T> vec) {
for (auto vv : vec)
cout << vv << " ";
cout << endl;
}
template <typename T> void Debug::vd2(vector<vector<T>> vec) {
for (auto vv : vec)
for (auto vvv : vv)
cout << vvv << " ";
cout << endl;
}
template <typename T> void Debug::ad(T *arr, ll n) {
for (int i = 0; i <= n; i++)
cout << arr[i] << " ";
cout << endl;
}
template <typename T, size_t N> void Debug::ad2(T (&arr)[N], ll n) {
for (int i = 0; i <= N; i++)
for (int j = 0; j <= n; j++)
cout << arr[i][j] << " ";
cout << endl;
}
template <typename T> void Debug::md(T mp) {
cout << "key : value" << endl;
for (auto const &m : mp)
cout << m.first << " : " << m.second << endl;
cout << endl;
}
} // namespace dbg
#endif // INCLUDE_DEBUG_HPP
using dbg::Debug;
Debug debug;
#ifndef DEFINE_COMBINATION_HPP
#define DEFINE_COMBINATION_HPP
using namespace std;
namespace comb {
using ll = long long;
ll mod = 1e9 + 7;
class Comb {
private:
ll powm(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1)
(res *= a) %= mod;
(a *= a) %= mod;
b >>= 1;
}
return res;
}
public:
vector<ll> fact;
vector<ll> finv;
vector<ll> inv;
Comb(){};
Comb(int n) { build(n); }
void build(int n);
ll res(int n, int k); // return nCk
ll resone(ll n, ll k);
};
void Comb::build(int n) {
inv.assign(n + 1, 0);
fact.assign(n + 1, 0);
finv.assign(n + 1, 0);
fact[0] = fact[1] = finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i <= n; i++) {
fact[i] = fact[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
ll Comb::res(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll Comb::resone(ll n, ll k) {
ll res = 1;
for (ll i = 0; i < k; i++) {
(res *= (n - i)) %= mod;
(res *= this->powm(i + 1, mod - 2)) %= mod;
}
return res;
}
} // namespace comb
#endif // DEFINE_COMBINATION_HPP
// verify
// https://atcoder.jp/contests/abc034/tasks/abc034_c
using comb::Comb;
class DBlueAndRedBalls {
public:
void solve(std::istream &in, std::ostream &out) {
ll n, k;
in >> n >> k;
Comb comb(n);
for (int i = 1; i <= k; i++) {
ll res = comb.res(n - k + 1, i) * comb.res(k - 1, i - 1);
out << res << endl;
}
}
};
int main() {
DBlueAndRedBalls solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9) + 7;
const ll inf = ll(5e18);
template <typename T1, typename T2> ll ceill(T1 a, T2 b) {
return (a + b - 1) / b;
}
void ans(bool b, ostream &out = cout) { out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream &out = cout) { out << (b ? "YES" : "NO") << endl; }
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP
#include <iostream>
#include <map>
#include <vector>
using namespace std;
namespace dbg {
using ll = long long;
class Debug {
public:
Debug() {}
template <typename T> void vd(vector<T> vec);
template <typename T> void vd2(vector<vector<T>> vec);
template <typename T> void ad(T *arr, ll n);
template <typename T, size_t N> void ad2(T (&arr)[N], ll n);
template <typename T> void md(T mp);
};
template <typename T> void Debug::vd(vector<T> vec) {
for (auto vv : vec)
cout << vv << " ";
cout << endl;
}
template <typename T> void Debug::vd2(vector<vector<T>> vec) {
for (auto vv : vec)
for (auto vvv : vv)
cout << vvv << " ";
cout << endl;
}
template <typename T> void Debug::ad(T *arr, ll n) {
for (int i = 0; i <= n; i++)
cout << arr[i] << " ";
cout << endl;
}
template <typename T, size_t N> void Debug::ad2(T (&arr)[N], ll n) {
for (int i = 0; i <= N; i++)
for (int j = 0; j <= n; j++)
cout << arr[i][j] << " ";
cout << endl;
}
template <typename T> void Debug::md(T mp) {
cout << "key : value" << endl;
for (auto const &m : mp)
cout << m.first << " : " << m.second << endl;
cout << endl;
}
} // namespace dbg
#endif // INCLUDE_DEBUG_HPP
using dbg::Debug;
Debug debug;
#ifndef DEFINE_COMBINATION_HPP
#define DEFINE_COMBINATION_HPP
using namespace std;
namespace comb {
using ll = long long;
ll mod = 1e9 + 7;
class Comb {
private:
ll powm(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1)
(res *= a) %= mod;
(a *= a) %= mod;
b >>= 1;
}
return res;
}
public:
vector<ll> fact;
vector<ll> finv;
vector<ll> inv;
Comb(){};
Comb(int n) { build(n); }
void build(int n);
ll res(int n, int k); // return nCk
ll resone(ll n, ll k);
};
void Comb::build(int n) {
inv.assign(n + 1, 0);
fact.assign(n + 1, 0);
finv.assign(n + 1, 0);
fact[0] = fact[1] = finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i <= n; i++) {
fact[i] = fact[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
ll Comb::res(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll Comb::resone(ll n, ll k) {
ll res = 1;
for (ll i = 0; i < k; i++) {
(res *= (n - i)) %= mod;
(res *= this->powm(i + 1, mod - 2)) %= mod;
}
return res;
}
} // namespace comb
#endif // DEFINE_COMBINATION_HPP
// verify
// https://atcoder.jp/contests/abc034/tasks/abc034_c
using comb::Comb;
class DBlueAndRedBalls {
public:
void solve(std::istream &in, std::ostream &out) {
ll n, k;
in >> n >> k;
Comb comb(n);
for (int i = 1; i <= k; i++) {
ll res = comb.res(n - k + 1, i) * comb.res(k - 1, i - 1) % mod;
out << res << endl;
}
}
};
int main() {
DBlueAndRedBalls solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| [
"assignment.change"
] | 797,364 | 797,365 | u026620445 | cpp |
p02990 | #define MOD 1000000007
#include <iostream>
#include <vector>
using namespace std;
long pow(long a, long b) {
if (!b)
return 1;
long c = pow(a, b / 2);
if (b % 2)
c = a * c % MOD * c % MOD;
else
c = c * c % MOD;
return c;
}
int main() {
int N, K;
cin >> N >> K;
vector<long> a(N + 1, 1), b(N + 1, 1);
for (int i = 1; i <= N; i++) {
a[i] = a[i - 1] * i % MOD;
b[i] = pow(a[i], MOD - 2);
}
for (int i = 1; i <= K; i++) {
if (N - K - 1 + 1 < 0)
cout << 0;
else {
long c = a[N - K + 1] * b[N - K - i + 1] % MOD * b[i] % MOD;
long d = a[K - 1] * b[K - i] % MOD * b[i - 1] % MOD;
cout << c * d % MOD;
}
cout << endl;
}
} | #define MOD 1000000007
#include <iostream>
#include <vector>
using namespace std;
long pow(long a, long b) {
if (!b)
return 1;
long c = pow(a, b / 2);
if (b % 2)
c = a * c % MOD * c % MOD;
else
c = c * c % MOD;
return c;
}
int main() {
int N, K;
cin >> N >> K;
vector<long> a(N + 1, 1), b(N + 1, 1);
for (int i = 1; i <= N; i++) {
a[i] = a[i - 1] * i % MOD;
b[i] = pow(a[i], MOD - 2);
}
for (int i = 1; i <= K; i++) {
if (N - K + 1 < i)
cout << 0;
else {
long c = a[N - K + 1] * b[N - K - i + 1] % MOD * b[i] % MOD;
long d = a[K - 1] * b[K - i] % MOD * b[i - 1] % MOD;
cout << c * d % MOD;
}
cout << endl;
}
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change"
] | 797,366 | 797,367 | u102795616 | cpp |
p02990 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
ll power(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b /= 2;
}
return res;
}
ll c(ll a, ll b) {
ll res = 1;
for (ll i = 1; i <= b; i++)
res = res * (a - i + 1) * power(i, mod - 2) % mod;
return res;
}
int main() {
int n, k;
cin >> n >> k;
ll r = n - k, b = k;
for (ll i = 1; i <= k; i++) {
ll bb = c(b - 1, i - 1) % mod;
if (r < i - 1) {
cout << 0 << endl;
continue;
}
ll rr = c(1 + r, i) % mod;
while (bb < 0)
bb += mod;
while (rr < 0)
rr += mod;
cout << bb * rr % mod << endl;
}
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
ll power(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b /= 2;
}
return res;
}
ll c(ll a, ll b) {
ll res = 1;
for (ll i = 1; i <= b; i++)
res = res * (a - i + 1) % mod * power(i, mod - 2) % mod;
return res;
}
int main() {
int n, k;
cin >> n >> k;
ll r = n - k, b = k;
for (ll i = 1; i <= k; i++) {
ll bb = c(b - 1, i - 1) % mod;
if (r < i - 1) {
cout << 0 << endl;
continue;
}
ll rr = c(1 + r, i) % mod;
while (bb < 0)
bb += mod;
while (rr < 0)
rr += mod;
cout << bb * rr % mod << endl;
}
}
| [
"assignment.change"
] | 797,372 | 797,373 | u724012411 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 1; i <= n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
//最大公約数
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
//素因数分解
map<int, int> prime_factor(ll n, map<int, int> &res) {
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
res[i]++;
n /= i;
}
}
if (n != 1) {
if (res[n] == 0) {
res[n] = 1;
} else {
res[n]++;
}
}
return res;
}
//約数列挙
vector<ll> divisor(ll n) {
vector<ll> a;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
a.push_back(i);
if (i * i != n) {
a.push_back(n / i);
}
}
}
SORT(a);
return a;
}
//拡張ユークリッドの互除法
int extgcd(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
int d = extgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
}
//素数判定
void sieve(int n, vector<bool> &is_prime) {
is_prime[0] = false;
is_prime[1] = false;
for (int i = 2; i * i <= n; i++) {
if (is_prime[i]) {
for (int j = i * i; j <= n; j += i)
is_prime[j] = false;
}
}
return;
}
//繰り返し2乗法
ll mod_pow(ll x, ll n, ll mod) {
x %= mod;
ll res = 1;
while (n > 0) {
if (n & 1) {
res = res * x % mod;
}
x = x * x % mod;
n >>= 1;
}
return res;
}
// mod m での a の逆元
int mod_inverse(ll a, ll m) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
vector<ll> factrial, inverse;
// nCkの前計算
void init(ll n, ll m) {
factrial.resize(n + 1);
inverse.resize(n + 1);
factrial[0] = 1;
inverse[0] = 1;
for (ll i = 1; i <= n; i++) {
factrial[i] = factrial[i - 1] * i % m;
inverse[i] = mod_inverse(factrial[i], m);
}
}
// nCk
ll nCk(ll n, ll k, ll m) {
if (n < 0 || k < 0 || n < k) {
return 0;
}
return factrial[n] * inverse[k] % m * inverse[n - k] % m;
}
int mod = 1e9 + 7;
vector<ll> a, b;
int main() {
int n, k;
cin >> n >> k;
ll ans = 0;
init(n, mod);
rep(i, k) { cout << nCk(n - k + 1, i, mod) * nCk(k - 1, i - 1, mod) << endl; }
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 1; i <= n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
//最大公約数
ll gcd(ll a, ll b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
//素因数分解
map<int, int> prime_factor(ll n, map<int, int> &res) {
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
res[i]++;
n /= i;
}
}
if (n != 1) {
if (res[n] == 0) {
res[n] = 1;
} else {
res[n]++;
}
}
return res;
}
//約数列挙
vector<ll> divisor(ll n) {
vector<ll> a;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
a.push_back(i);
if (i * i != n) {
a.push_back(n / i);
}
}
}
SORT(a);
return a;
}
//拡張ユークリッドの互除法
int extgcd(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
int d = extgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
}
//素数判定
void sieve(int n, vector<bool> &is_prime) {
is_prime[0] = false;
is_prime[1] = false;
for (int i = 2; i * i <= n; i++) {
if (is_prime[i]) {
for (int j = i * i; j <= n; j += i)
is_prime[j] = false;
}
}
return;
}
//繰り返し2乗法
ll mod_pow(ll x, ll n, ll mod) {
x %= mod;
ll res = 1;
while (n > 0) {
if (n & 1) {
res = res * x % mod;
}
x = x * x % mod;
n >>= 1;
}
return res;
}
// mod m での a の逆元
int mod_inverse(ll a, ll m) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
vector<ll> factrial, inverse;
// nCkの前計算
void init(ll n, ll m) {
factrial.resize(n + 1);
inverse.resize(n + 1);
factrial[0] = 1;
inverse[0] = 1;
for (ll i = 1; i <= n; i++) {
factrial[i] = factrial[i - 1] * i % m;
inverse[i] = mod_inverse(factrial[i], m);
}
}
// nCk
ll nCk(ll n, ll k, ll m) {
if (n < 0 || k < 0 || n < k) {
return 0;
}
return factrial[n] * inverse[k] % m * inverse[n - k] % m;
}
int mod = 1e9 + 7;
vector<ll> a, b;
int main() {
int n, k;
cin >> n >> k;
ll ans = 0;
init(n, mod);
rep(i, k) {
cout << (nCk(n - k + 1, i, mod) * nCk(k - 1, i - 1, mod)) % mod << endl;
}
}
| [
"expression.operation.binary.add"
] | 797,384 | 797,385 | u310228685 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[2005][2005], mod = 1e9 + 7;
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 0; i <= 2002; i++) {
c[i][0] = c[i][i] = 1;
for (ll j = 1; j < i; j++) {
c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
}
for (ll i = 1; i <= k; i++) {
if (n - k + 1 < i)
cout << 0 << endl;
else
cout << c[n - k + 1][i] % mod * c[k - 1][i - 1] << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[2005][2005], mod = 1e9 + 7;
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 0; i <= 2002; i++) {
c[i][0] = c[i][i] = 1;
for (ll j = 1; j < i; j++) {
c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
}
for (ll i = 1; i <= k; i++) {
if (n - k + 1 < i)
cout << 0 << endl;
else
cout << (c[n - k + 1][i] % mod * c[k - 1][i - 1] % mod) % mod << endl;
}
} | [
"expression.operation.binary.add"
] | 797,392 | 797,393 | u089147470 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
static const double pi = 3.141592653589793;
typedef pair<int64_t, int64_t> P;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
// 前処理
COMinit();
int64_t a, b;
cin >> a >> b;
for (int i = 1; i <= b; i++) {
cout << COM(b - 1, i - 1) * COM(a - b + 1, i) << endl;
}
// 計算例
}
| #include <bits/stdc++.h>
using namespace std;
static const double pi = 3.141592653589793;
typedef pair<int64_t, int64_t> P;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
// 前処理
COMinit();
int64_t a, b;
cin >> a >> b;
for (int i = 1; i <= b; i++) {
cout << COM(b - 1, i - 1) * COM(a - b + 1, i) % MOD << endl;
}
// 計算例
}
| [
"expression.operation.binary.add"
] | 797,398 | 797,399 | u398685345 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
const int MAX = 2200;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; i++) {
cout << COM(n - k + 1, i) * COM(k - 1, i - 1) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
const int MAX = 2200;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; i++) {
cout << (COM(n - k + 1, i) * COM(k - 1, i - 1)) % MOD << endl;
}
} | [
"expression.operation.binary.add"
] | 797,400 | 797,401 | u251779460 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
const int MAX = 10000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; i++) {
cout << COM(n - k + 1, i) * COM(k - 1, i - 1) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
const int MAX = 2200;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; i++) {
cout << (COM(n - k + 1, i) * COM(k - 1, i - 1)) % MOD << endl;
}
} | [
"literal.number.change",
"variable_declaration.value.change"
] | 797,402 | 797,401 | u251779460 | cpp |
p02990 | #include <bits/stdc++.h>
using ll = int_fast64_t;
const ll MOD = 1e9 + 7;
ll fact[100000], finv[100000], inv[100000];
void combinit() {
fact[0] = fact[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll i = 2; i < 100000; i++) {
fact[i] = fact[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll comb(ll n, ll k) {
if (n < k or n < 0 or k < 0)
return 0;
return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n, k;
scanf("%ld %ld", &n, &k);
combinit();
ll r = n - k;
for (ll b = 1; b <= k; b++) {
printf("%ld\n", comb(r + 1, b) * comb(k - 1, b - 1));
}
return 0;
} | #include <bits/stdc++.h>
using ll = int_fast64_t;
const ll MOD = 1e9 + 7;
ll fact[100000], finv[100000], inv[100000];
void combinit() {
fact[0] = fact[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll i = 2; i < 100000; i++) {
fact[i] = fact[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll comb(ll n, ll k) {
if (n < k or n < 0 or k < 0)
return 0;
return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n, k;
scanf("%ld %ld", &n, &k);
combinit();
ll r = n - k;
for (ll b = 1; b <= k; b++) {
printf("%ld\n", comb(r + 1, b) * comb(k - 1, k - b) % MOD);
}
return 0;
}
| [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"identifier.replace.add",
"literal.replace.remove"
] | 797,411 | 797,412 | u242031676 | cpp |
p02990 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const int MAX = 200500;
// fac: 階乗, finv: 階乗の逆元, inv: 逆元
ll fac[MAX], finv[MAX], inv[MAX];
void cominit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
ll com(int n, int k) {
if (n < k)
return 0;
if (n < 0 or k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// abc132d
int main() {
ll n, k;
cin >> n >> k;
cominit();
for (ll i = 1; i <= k; i++) {
ll ans = 0;
ans = com(n - k + 1, i) * com(k - 1, i - 1);
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const int MAX = 200500;
// fac: 階乗, finv: 階乗の逆元, inv: 逆元
ll fac[MAX], finv[MAX], inv[MAX];
void cominit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
ll com(int n, int k) {
if (n < k)
return 0;
if (n < 0 or k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// abc132d
int main() {
ll n, k;
cin >> n >> k;
cominit();
for (ll i = 1; i <= k; i++) {
ll ans = 0;
ans = com(n - k + 1, i) * com(k - 1, i - 1) % mod;
cout << ans << endl;
}
return 0;
}
| [
"assignment.change"
] | 797,414 | 797,415 | u770009793 | cpp |
p02990 | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <climits>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <utility>
#include <vector>
//#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
const double pi = acos(-1.0);
// memset ( a , 0 , n * sizeof(ll) ) ;
using namespace std;
// using namespace __gnu_pbds;
#define endl '\n'
#define sl(n) scanf("%lld", &n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define f(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a, b) memset((a), (b), sizeof(a))
#define vec(g1) \
int temp; \
cin >> temp; \
g1, push_back(temp);
#define abs(x) ((x < 0) ? (-(x)) : (x))
#define MAX 1000005
#define inf LLONG_MAX
#define MIN INT_MIN
#define yeet return 0;
#define fast_io \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2
// source.cpp
inline long long MAX2(long long a, long long b) {
return (a) > (b) ? (a) : (b);
}
inline long long MAX3(long long a, long long b, long long c) {
return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long MIN2(long long a, long long b) {
return (a) < (b) ? (a) : (b);
}
inline long long MIN3(long long a, long long b, long long c) {
return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
int mod = 1e9 + 9;
// int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {if (!a) {x =
// 0;y = 1;return b;}int64_t x1, y1;int64_t d = extGcd(b % a, a, x1, y1);x = y1
// - (b / a) * x1;y = x1;return d;} const int factRange = 1000000; int
// fact[factRange]; inline int addMod(int a, int b, int m = mod) {return
// ((int64_t)a + b) % m;} inline int mulMod(int a, int b, int m = mod) { return
// ((int64_t)a * b) % m;} inline int divMod(int a, int b, int m = mod) {int64_t
// x, y;int64_t g = extGcd(b, m, x, y);if (g != 1) {cerr << "Bad gcd!" <<
// endl;for (;;);}x = (x % m + m) % m;return mulMod(a, x, m);} inline void
// precalcFactorials() {fact[0] = 1;for (int i = 1; i < factRange; i++) {fact[i]
// = mulMod(fact[i-1], i);}} inline int F(int n) {return (n < 0) ? 0 : fact[n];}
// inline int C(int k, int n) {return divMod(F(n), mulMod(F(n-k), F(k)));}
inline ll exp(ll a, ll b) {
if (a == 0)
return 0ll;
ll r = 1LL;
while (b > 0) {
if (b & 1) {
r = r * (a % mod);
r = (r + mod) % mod;
}
b /= 2;
a = (a % mod) * (a % mod);
a = (a + mod) % mod;
}
return (r + mod) % mod;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
if (a == 0)
return b;
return gcd(b, a % b);
}
inline ll poww(ll a, ll b) {
ll r = 1LL;
while (b > 0) {
if (b & 1)
r = r * a;
b /= 2;
a = a * a;
}
return (ll)r;
}
uint32 setbits(ll n) {
uint32 count = 0;
while (n) {
n &= (n - 1);
count++;
}
return count;
}
// const int N= 10000000;int lp[N+1];vector<int> pr;void seive(){for (int i=2;
// i<=N; ++i) {if (lp[i] == 0) {lp[i] = i;pr.push_back (i);}for (int j=0;
// j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j) lp[i * pr[j]] = pr[j]; }}
////****************************************************************************************************************************************************************************************************************////
ll C[2005][2005];
void ncr() { // play table
C[0][0] = 1;
for (int i = 1; i < 2005; i++) {
C[i][0] = C[i][i] = 1;
for (int j = 1; j <= i; j++) {
C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
}
}
}
int main() {
int n, k;
cin >> n >> k;
ncr();
ll ans = 0;
for (int i = 1; i <= k; i++) {
ans = (C[n - k + 1][i] % mod * C[k - 1][i - 1] % mod) % mod;
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <climits>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <utility>
#include <vector>
//#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
const double pi = acos(-1.0);
// memset ( a , 0 , n * sizeof(ll) ) ;
using namespace std;
// using namespace __gnu_pbds;
#define endl '\n'
#define sl(n) scanf("%lld", &n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define f(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a, b) memset((a), (b), sizeof(a))
#define vec(g1) \
int temp; \
cin >> temp; \
g1, push_back(temp);
#define abs(x) ((x < 0) ? (-(x)) : (x))
#define MAX 1000005
#define inf LLONG_MAX
#define MIN INT_MIN
#define yeet return 0;
#define fast_io \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2
// source.cpp
inline long long MAX2(long long a, long long b) {
return (a) > (b) ? (a) : (b);
}
inline long long MAX3(long long a, long long b, long long c) {
return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long MIN2(long long a, long long b) {
return (a) < (b) ? (a) : (b);
}
inline long long MIN3(long long a, long long b, long long c) {
return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
int mod = 1e9 + 7;
// int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {if (!a) {x =
// 0;y = 1;return b;}int64_t x1, y1;int64_t d = extGcd(b % a, a, x1, y1);x = y1
// - (b / a) * x1;y = x1;return d;} const int factRange = 1000000; int
// fact[factRange]; inline int addMod(int a, int b, int m = mod) {return
// ((int64_t)a + b) % m;} inline int mulMod(int a, int b, int m = mod) { return
// ((int64_t)a * b) % m;} inline int divMod(int a, int b, int m = mod) {int64_t
// x, y;int64_t g = extGcd(b, m, x, y);if (g != 1) {cerr << "Bad gcd!" <<
// endl;for (;;);}x = (x % m + m) % m;return mulMod(a, x, m);} inline void
// precalcFactorials() {fact[0] = 1;for (int i = 1; i < factRange; i++) {fact[i]
// = mulMod(fact[i-1], i);}} inline int F(int n) {return (n < 0) ? 0 : fact[n];}
// inline int C(int k, int n) {return divMod(F(n), mulMod(F(n-k), F(k)));}
inline ll exp(ll a, ll b) {
if (a == 0)
return 0ll;
ll r = 1LL;
while (b > 0) {
if (b & 1) {
r = r * (a % mod);
r = (r + mod) % mod;
}
b /= 2;
a = (a % mod) * (a % mod);
a = (a + mod) % mod;
}
return (r + mod) % mod;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
if (a == 0)
return b;
return gcd(b, a % b);
}
inline ll poww(ll a, ll b) {
ll r = 1LL;
while (b > 0) {
if (b & 1)
r = r * a;
b /= 2;
a = a * a;
}
return (ll)r;
}
uint32 setbits(ll n) {
uint32 count = 0;
while (n) {
n &= (n - 1);
count++;
}
return count;
}
// const int N= 10000000;int lp[N+1];vector<int> pr;void seive(){for (int i=2;
// i<=N; ++i) {if (lp[i] == 0) {lp[i] = i;pr.push_back (i);}for (int j=0;
// j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j) lp[i * pr[j]] = pr[j]; }}
////****************************************************************************************************************************************************************************************************************////
ll C[2005][2005];
void ncr() { // play table
C[0][0] = 1;
for (int i = 1; i < 2005; i++) {
C[i][0] = C[i][i] = 1;
for (int j = 1; j <= i; j++) {
C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
}
}
}
int main() {
int n, k;
cin >> n >> k;
ncr();
ll ans = 0;
for (int i = 1; i <= k; i++) {
ans = (C[n - k + 1][i] * C[k - 1][i - 1]) % mod;
cout << ans << endl;
}
return 0;
} | [
"literal.number.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 797,424 | 797,425 | u645188582 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, d, n) for (int i = (d); i < (n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int MAX = 2000;
const int mod = 1e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; ++i) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
ll Combination(int n, int k) {
if (n < k) {
return 0;
}
if (n < 0 || k < 0) {
return 0;
}
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; ++i) {
if (i == 1) {
cout << n - k + 1 << endl;
} else if (i == k) {
cout << Combination(n - k + 1, k) << endl;
} else {
cout << Combination(k - 1, i - 1) * Combination(n - k + 1, k - i + 1) %
mod
<< endl;
}
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, d, n) for (int i = (d); i < (n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int MAX = 2000;
const int mod = 1e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; ++i) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
ll Combination(int n, int k) {
if (n < k) {
return 0;
}
if (n < 0 || k < 0) {
return 0;
}
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
for (int i = 1; i <= k; ++i) {
if (i == 1) {
cout << n - k + 1 << endl;
} else if (i == k) {
cout << Combination(n - k + 1, k) << endl;
} else {
cout << Combination(k - 1, i - 1) * Combination(n - k + 1, i) % mod
<< endl;
}
}
return 0;
} | [
"expression.operation.binary.remove"
] | 797,428 | 797,429 | u561143568 | cpp |
p02990 | #include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)
#define pb push_back
#define all(in) in.begin(), in.end()
using ll = long long;
using ull = unsigned long long;
using namespace std;
const ll MOD = 1e9 + 7;
vector<vector<int>> com(2000, vector<int>(2000, 0));
void COM() {
com[0][0] = 1;
for (int i = 1; i < 2000; i++) {
com[i][0] = 1;
for (int j = 1; j <= i; ++j) {
com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % MOD;
}
}
}
int main() {
ll n, k;
cin >> n >> k;
COM();
loop(i, 1, k + 1) {
ll ans;
if (n - k + 1 >= i)
ans = (com[n - k + 1][i] * com[k - 1][i - 1]) % MOD;
else
ans = 0;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)
#define pb push_back
#define all(in) in.begin(), in.end()
using ll = long long;
using ull = unsigned long long;
using namespace std;
const ll MOD = 1e9 + 7;
vector<vector<ll>> com(20020, vector<ll>(2020, 0));
void COM() {
com[0][0] = 1;
for (int i = 1; i < 2020; i++) {
com[i][0] = 1;
for (int j = 1; j <= i; ++j) {
com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % MOD;
}
}
}
int main() {
ll n, k;
cin >> n >> k;
COM();
loop(i, 1, k + 1) {
ll ans;
if (n - k + 1 >= i)
ans = (com[n - k + 1][i] * com[k - 1][i - 1]) % MOD;
else
ans = 0;
cout << ans << endl;
}
} | [
"literal.number.change",
"call.arguments.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 797,430 | 797,431 | u842028864 | cpp |
p02990 | ///////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <typeinfo>
#include <unistd.h>
#include <unordered_map>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
#define pb push_back
#define V vector
#define M unordered_map
#define rep(i, n) for (int i = 0; i < n; ++i)
#define srep(i, s, n) for (int i = s; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll, ll> t2;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
struct UnionFind {
ull *parent, *count, *rank;
UnionFind(ull n) {
parent = new ull[n + 1];
count = new ull[n + 1];
rank = new ull[n + 1];
for (ull i = 0ULL; i < n + 1; ++i) {
parent[i] = i;
count[i] = 1;
rank[i] = 0;
}
}
ull root(ull i) {
if (parent[i] == i)
return i;
parent[i] = root(parent[i]);
return parent[i];
}
void unite(ull i, ull j) {
ull rooti = root(i);
ull rootj = root(j);
if (rooti == rootj)
return;
if (rank[rootj] < rank[rooti]) {
parent[i] = parent[j] = parent[rootj] = rooti;
count[rooti] += count[rootj];
} else {
parent[i] = parent[j] = parent[rooti] = rootj;
count[rootj] += count[rooti];
if (rank[rootj] == rank[rooti])
rank[rootj]++;
}
}
bool same(ull i, ull j) { return root(i) == root(j); }
};
struct BIT {
ll *tree;
ll size;
BIT(ll n, ll init) {
tree = new ll[n + 1];
size = n;
rep(i, n + 1) tree[i] = init;
}
// idx is 1 origin
void add(ll idx, ll x) {
assert(idx > 0LL);
while (idx <= size) {
tree[idx] += x;
idx += (idx & (-idx));
}
}
// idx is 1 origin
ll sum(ll idx) {
assert(idx > 0LL);
ll ret = 0LL;
while (idx > 0LL) {
ret += tree[idx];
idx -= (idx & (-idx));
}
return ret;
}
};
struct MaxFlow {
V<ll> links[1005];
ll capacities[1005][1005];
ll nodes;
MaxFlow(ll nodes) {
// i == 0 --> S
// i == nodes+1 --> T
rep(i, nodes + 2LL) links[i].clear();
memset(capacities, 0, sizeof(capacities));
this->nodes = nodes;
}
void add_path(ll a, ll b, ll capacity) {
links[a].pb(b);
links[b].pb(a);
capacities[a][b] = capacity;
capacities[b][a] = 0LL;
}
ll solve(void) {
deque<V<ll>> q;
ll ret = 0LL;
for (;; q.clear()) {
V<ll> start;
start.pb(0);
q.push_front(start);
bool checked[nodes + 2];
memset(checked, 0, sizeof(checked));
V<ll> found;
for (; !(q.empty());) {
V<ll> path = q.front();
q.pop_front();
ll last = path[path.size() - 1];
if (checked[last])
continue;
if (last == nodes + 1) {
found = path;
break;
}
checked[last] = true;
for (auto next : (links[last])) {
if (capacities[last][next] == 0)
continue;
V<ll> newpath(path);
newpath.pb(next);
q.push_front(newpath);
}
}
if (found.size() == 0) {
break;
} else {
ll flowcount = capacities[found[0]][found[1]];
rep(i, found.size() - 1) {
ll src = found[i];
ll dst = found[i + 1];
flowcount = min(flowcount, capacities[src][dst]);
}
rep(i, found.size() - 1) {
ll src = found[i];
ll dst = found[i + 1];
capacities[src][dst] -= flowcount;
capacities[dst][src] += flowcount;
}
ret += flowcount;
}
}
return ret;
}
};
void llin(ll &a) { cin >> a; }
void llinl1(auto &v, ll count) {
for (ll i = 0LL; i < count; ++i) {
ll a;
cin >> a;
v.push_back(a);
}
}
void llinl2(auto &v, ll count) {
for (ll i = 0LL; i < count; ++i) {
ll a, b;
cin >> a >> b;
v.push_back(tuple<ll, ll>(a, b));
}
}
void llinl3(auto &v, ll count) {
for (ll i = 0LL; i < count; ++i) {
ll a, b, c;
cin >> a >> b >> c;
v.push_back(tuple<ll, ll, ll>(a, b, c));
}
}
void llina(auto &v, ll count) { llinl1(v, count); }
template <typename T> T min(const V<T> v) {
T ret = v[0];
for (auto i : v)
ret = min(ret, i);
return ret;
}
template <typename T> T max(const V<T> v) {
T ret = v[0];
for (auto i : v)
ret = max(ret, i);
return ret;
}
ll absll(ll x) {
if (x < 0)
return -x;
return x;
}
ll mod_mlt(ll x, ll y, ll mod) {
ll ret = 0LL;
x %= mod;
while (y) {
if (y & 1LL) {
ret += x;
ret %= mod;
}
y >>= 1;
x <<= 1;
x %= mod;
}
return ret;
}
ll mod_pow(ll base, ll exp, ll mod) {
ll ret = 1LL;
for (; exp;) {
if (exp & 1LL) {
ret *= base;
ret %= mod;
}
base = (base * base) % mod;
exp >>= 1;
}
return ret;
}
ll mod_inv(ll x, ll mod) {
// available only when mod is prime
return mod_pow(x, mod - 2LL, mod);
}
ll gcm(ll x, ll y) {
while (y != 0) {
ll z = x % y;
x = y;
y = z;
}
return x;
}
template <typename T> void sort(V<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void sort_reverse(V<T> &v) {
sort(v.begin(), v.end(), greater<T>());
}
void get_divisors(V<ll> &retlist, ll x) {
for (ll i = 1LL; i < sqrt(x) + 3LL; ++i) {
if (x % i == 0LL) {
retlist.push_back(i);
retlist.push_back(x / i);
}
}
}
void get_factors(V<ll> &retlist, ll x) {
for (ll i = 2LL; i < (ll)(sqrt(x)) + 3LL; ++i) {
while (x % i == 0LL) {
retlist.pb(i);
x /= i;
}
}
retlist.pb(x);
}
bool is_prime(ll x) {
V<ll> factors, factors2;
get_factors(factors, x);
for (auto factor : factors) {
if (factor > 1)
factors2.pb(factor);
}
return factors2.size() == 1 && x == factors2[0];
}
template <typename T>
void intersection(const set<T> &a, const set<T> &b, set<T> &result) {
V<T> resultlist;
set_intersection(a.begin(), a.end(), b.begin(), b.end(),
back_inserter(resultlist));
set<T> resultset(resultlist.begin(), resultlist.end());
result = resultset;
}
ull combination(ll x, ll y) {
if (y > x / 2LL)
y = x - y;
ull ret = 1LL;
for (ll i = 0LL; i < y; ++i) {
ret *= x--;
ret /= (i + 1LL);
}
return ret;
}
ull mod_combination(ll x, ll y, ll mod) {
if (y > x / 2LL)
y = x - y;
ll ret = 1;
for (ll i = 0LL; i < y; ++i) {
ret = (ret * x--) % mod;
ret = (ret * mod_inv(i + 1LL, mod)) % mod;
}
return ret;
}
void make_linklist(const V<tuple<ll, ll>> &srclist, V<V<ll>> &dstlist) {
for (auto src : srclist) {
ll a = get<0>(src);
ll b = get<1>(src);
dstlist[a].pb(b);
dstlist[b].pb(a);
}
}
void debug_print(auto x) { cout << x << endl; }
void debug_print(const t2 &x) {
ll x1 = get<0>(x);
ll x2 = get<1>(x);
cout << "-- " << x1 << " -- " << x2 << endl;
}
void debug_print(const t3 &x) {
ll x1 = get<0>(x);
ll x2 = get<1>(x);
ll x3 = get<2>(x);
cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << endl;
}
void debug_print(const t4 &x) {
ll x1 = get<0>(x);
ll x2 = get<1>(x);
ll x3 = get<2>(x);
ll x4 = get<3>(x);
cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << " -- " << x4 << endl;
}
template <typename T> void debug_print(T xarray[], ll n) {
rep(i, n) debug_print(xarray[i]);
}
template <typename T> void debug_print(const V<T> &xlist) {
for (auto x : xlist) {
cout << "-- ";
debug_print(x);
}
}
template <typename S, typename T> void debug_print(const M<S, T> &xlist) {
for (auto x : xlist) {
S k = x.first;
T v = x.second;
cout << "====" << endl;
cout << "K=";
debug_print(k);
cout << "V=";
debug_print(v);
}
}
int _main();
int main() {
cout << setprecision(12);
return _main();
}
///////////////////////////////////////////////////////////////////////////////
ll mod = pow(10, 9) + 7LL;
ll memo_f[2005][2005];
ll f(ll nrball, ll nrslot) {
if (memo_f[nrball][nrslot] >= 0LL)
return memo_f[nrball][nrslot];
if (nrball == 0LL)
return 1LL;
if (nrslot == 1LL)
return 1LL;
ll ret = f(nrball, nrslot - 1) + f(nrball - 1, nrslot);
memo_f[nrball][nrslot] = ret;
return ret;
}
int _main() {
ll n, k;
llin(n);
llin(k);
rep(i, 2005) {
rep(j, 2005) { memo_f[i][j] = -1LL; }
}
rep(i0, k) {
ll i = (ll)i0 + 1LL;
ll blue = k - i;
ll red = n - k - (i - 1LL);
if (blue < 0 || red < 0) {
cout << 0 << endl;
continue;
}
ll ans = 1LL;
ans *= f(blue, i);
ans %= mod;
ans *= f(red, i + 1);
ans %= mod;
cout << ans << endl;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
| ///////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <typeinfo>
#include <unistd.h>
#include <unordered_map>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
#define pb push_back
#define V vector
#define M unordered_map
#define rep(i, n) for (int i = 0; i < n; ++i)
#define srep(i, s, n) for (int i = s; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll, ll> t2;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
struct UnionFind {
ull *parent, *count, *rank;
UnionFind(ull n) {
parent = new ull[n + 1];
count = new ull[n + 1];
rank = new ull[n + 1];
for (ull i = 0ULL; i < n + 1; ++i) {
parent[i] = i;
count[i] = 1;
rank[i] = 0;
}
}
ull root(ull i) {
if (parent[i] == i)
return i;
parent[i] = root(parent[i]);
return parent[i];
}
void unite(ull i, ull j) {
ull rooti = root(i);
ull rootj = root(j);
if (rooti == rootj)
return;
if (rank[rootj] < rank[rooti]) {
parent[i] = parent[j] = parent[rootj] = rooti;
count[rooti] += count[rootj];
} else {
parent[i] = parent[j] = parent[rooti] = rootj;
count[rootj] += count[rooti];
if (rank[rootj] == rank[rooti])
rank[rootj]++;
}
}
bool same(ull i, ull j) { return root(i) == root(j); }
};
struct BIT {
ll *tree;
ll size;
BIT(ll n, ll init) {
tree = new ll[n + 1];
size = n;
rep(i, n + 1) tree[i] = init;
}
// idx is 1 origin
void add(ll idx, ll x) {
assert(idx > 0LL);
while (idx <= size) {
tree[idx] += x;
idx += (idx & (-idx));
}
}
// idx is 1 origin
ll sum(ll idx) {
assert(idx > 0LL);
ll ret = 0LL;
while (idx > 0LL) {
ret += tree[idx];
idx -= (idx & (-idx));
}
return ret;
}
};
struct MaxFlow {
V<ll> links[1005];
ll capacities[1005][1005];
ll nodes;
MaxFlow(ll nodes) {
// i == 0 --> S
// i == nodes+1 --> T
rep(i, nodes + 2LL) links[i].clear();
memset(capacities, 0, sizeof(capacities));
this->nodes = nodes;
}
void add_path(ll a, ll b, ll capacity) {
links[a].pb(b);
links[b].pb(a);
capacities[a][b] = capacity;
capacities[b][a] = 0LL;
}
ll solve(void) {
deque<V<ll>> q;
ll ret = 0LL;
for (;; q.clear()) {
V<ll> start;
start.pb(0);
q.push_front(start);
bool checked[nodes + 2];
memset(checked, 0, sizeof(checked));
V<ll> found;
for (; !(q.empty());) {
V<ll> path = q.front();
q.pop_front();
ll last = path[path.size() - 1];
if (checked[last])
continue;
if (last == nodes + 1) {
found = path;
break;
}
checked[last] = true;
for (auto next : (links[last])) {
if (capacities[last][next] == 0)
continue;
V<ll> newpath(path);
newpath.pb(next);
q.push_front(newpath);
}
}
if (found.size() == 0) {
break;
} else {
ll flowcount = capacities[found[0]][found[1]];
rep(i, found.size() - 1) {
ll src = found[i];
ll dst = found[i + 1];
flowcount = min(flowcount, capacities[src][dst]);
}
rep(i, found.size() - 1) {
ll src = found[i];
ll dst = found[i + 1];
capacities[src][dst] -= flowcount;
capacities[dst][src] += flowcount;
}
ret += flowcount;
}
}
return ret;
}
};
void llin(ll &a) { cin >> a; }
void llinl1(auto &v, ll count) {
for (ll i = 0LL; i < count; ++i) {
ll a;
cin >> a;
v.push_back(a);
}
}
void llinl2(auto &v, ll count) {
for (ll i = 0LL; i < count; ++i) {
ll a, b;
cin >> a >> b;
v.push_back(tuple<ll, ll>(a, b));
}
}
void llinl3(auto &v, ll count) {
for (ll i = 0LL; i < count; ++i) {
ll a, b, c;
cin >> a >> b >> c;
v.push_back(tuple<ll, ll, ll>(a, b, c));
}
}
void llina(auto &v, ll count) { llinl1(v, count); }
template <typename T> T min(const V<T> v) {
T ret = v[0];
for (auto i : v)
ret = min(ret, i);
return ret;
}
template <typename T> T max(const V<T> v) {
T ret = v[0];
for (auto i : v)
ret = max(ret, i);
return ret;
}
ll absll(ll x) {
if (x < 0)
return -x;
return x;
}
ll mod_mlt(ll x, ll y, ll mod) {
ll ret = 0LL;
x %= mod;
while (y) {
if (y & 1LL) {
ret += x;
ret %= mod;
}
y >>= 1;
x <<= 1;
x %= mod;
}
return ret;
}
ll mod_pow(ll base, ll exp, ll mod) {
ll ret = 1LL;
for (; exp;) {
if (exp & 1LL) {
ret *= base;
ret %= mod;
}
base = (base * base) % mod;
exp >>= 1;
}
return ret;
}
ll mod_inv(ll x, ll mod) {
// available only when mod is prime
return mod_pow(x, mod - 2LL, mod);
}
ll gcm(ll x, ll y) {
while (y != 0) {
ll z = x % y;
x = y;
y = z;
}
return x;
}
template <typename T> void sort(V<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void sort_reverse(V<T> &v) {
sort(v.begin(), v.end(), greater<T>());
}
void get_divisors(V<ll> &retlist, ll x) {
for (ll i = 1LL; i < sqrt(x) + 3LL; ++i) {
if (x % i == 0LL) {
retlist.push_back(i);
retlist.push_back(x / i);
}
}
}
void get_factors(V<ll> &retlist, ll x) {
for (ll i = 2LL; i < (ll)(sqrt(x)) + 3LL; ++i) {
while (x % i == 0LL) {
retlist.pb(i);
x /= i;
}
}
retlist.pb(x);
}
bool is_prime(ll x) {
V<ll> factors, factors2;
get_factors(factors, x);
for (auto factor : factors) {
if (factor > 1)
factors2.pb(factor);
}
return factors2.size() == 1 && x == factors2[0];
}
template <typename T>
void intersection(const set<T> &a, const set<T> &b, set<T> &result) {
V<T> resultlist;
set_intersection(a.begin(), a.end(), b.begin(), b.end(),
back_inserter(resultlist));
set<T> resultset(resultlist.begin(), resultlist.end());
result = resultset;
}
ull combination(ll x, ll y) {
if (y > x / 2LL)
y = x - y;
ull ret = 1LL;
for (ll i = 0LL; i < y; ++i) {
ret *= x--;
ret /= (i + 1LL);
}
return ret;
}
ull mod_combination(ll x, ll y, ll mod) {
if (y > x / 2LL)
y = x - y;
ll ret = 1;
for (ll i = 0LL; i < y; ++i) {
ret = (ret * x--) % mod;
ret = (ret * mod_inv(i + 1LL, mod)) % mod;
}
return ret;
}
void make_linklist(const V<tuple<ll, ll>> &srclist, V<V<ll>> &dstlist) {
for (auto src : srclist) {
ll a = get<0>(src);
ll b = get<1>(src);
dstlist[a].pb(b);
dstlist[b].pb(a);
}
}
void debug_print(auto x) { cout << x << endl; }
void debug_print(const t2 &x) {
ll x1 = get<0>(x);
ll x2 = get<1>(x);
cout << "-- " << x1 << " -- " << x2 << endl;
}
void debug_print(const t3 &x) {
ll x1 = get<0>(x);
ll x2 = get<1>(x);
ll x3 = get<2>(x);
cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << endl;
}
void debug_print(const t4 &x) {
ll x1 = get<0>(x);
ll x2 = get<1>(x);
ll x3 = get<2>(x);
ll x4 = get<3>(x);
cout << "-- " << x1 << " -- " << x2 << " -- " << x3 << " -- " << x4 << endl;
}
template <typename T> void debug_print(T xarray[], ll n) {
rep(i, n) debug_print(xarray[i]);
}
template <typename T> void debug_print(const V<T> &xlist) {
for (auto x : xlist) {
cout << "-- ";
debug_print(x);
}
}
template <typename S, typename T> void debug_print(const M<S, T> &xlist) {
for (auto x : xlist) {
S k = x.first;
T v = x.second;
cout << "====" << endl;
cout << "K=";
debug_print(k);
cout << "V=";
debug_print(v);
}
}
int _main();
int main() {
cout << setprecision(12);
return _main();
}
///////////////////////////////////////////////////////////////////////////////
ll mod = pow(10, 9) + 7LL;
ll memo_f[2005][2005];
ll f(ll nrball, ll nrslot) {
if (memo_f[nrball][nrslot] >= 0LL)
return memo_f[nrball][nrslot];
if (nrball == 0LL)
return 1LL;
if (nrslot == 1LL)
return 1LL;
ll ret = f(nrball, nrslot - 1) + f(nrball - 1, nrslot);
ret %= mod;
memo_f[nrball][nrslot] = ret;
return ret;
}
int _main() {
ll n, k;
llin(n);
llin(k);
rep(i, 2005) {
rep(j, 2005) { memo_f[i][j] = -1LL; }
}
rep(i0, k) {
ll i = (ll)i0 + 1LL;
ll blue = k - i;
ll red = n - k - (i - 1LL);
if (blue < 0 || red < 0) {
cout << 0 << endl;
continue;
}
ll ans = 1LL;
ans *= f(blue, i);
ans %= mod;
ans *= f(red, i + 1);
ans %= mod;
cout << ans << endl;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
| [
"assignment.add"
] | 797,432 | 797,433 | u167931717 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll MOD = 1000000007;
const int MAX = 4001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
rep(i, k) { cout << COM(n - k + 1, i + 1) * COM(k - 1, i) << endl; }
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll MOD = 1000000007;
const int MAX = 4001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
COMinit();
rep(i, k) { cout << COM(n - k + 1, i + 1) * COM(k - 1, i) % MOD << endl; }
return 0;
}
| [
"expression.operation.binary.add"
] | 797,434 | 797,435 | u225642513 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define MOD 1000000007
#define IINF INT_MAX
#define INF 1LL << 30
ll modPow(ll x, ll a) {
if (a == 1)
return x;
if (a % 2)
return (x * modPow(x, a - 1)) % MOD;
ll t = modPow(x, a / 2);
return (t * t) % MOD;
}
ll modInv(ll x) { return modPow(x, MOD - 2); }
ll modPerm(ll n, ll k) {
ll ret = 1;
for (int i = 0; i < k; i++) {
ret = (ret * (n - i)) % MOD;
}
return ret;
}
ll modComb(ll n, ll k) {
ll a, b;
a = modPerm(n, k);
b = modPerm(k, k);
return (a * modInv(b)) % MOD;
}
int main() {
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << modComb(n - k + 1, i) * modComb(k - 1, i - 1) << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define MOD 1000000007
#define IINF INT_MAX
#define INF 1LL << 30
ll modPow(ll x, ll a) {
if (a == 1)
return x;
if (a % 2)
return (x * modPow(x, a - 1)) % MOD;
ll t = modPow(x, a / 2);
return (t * t) % MOD;
}
ll modInv(ll x) { return modPow(x, MOD - 2); }
ll modPerm(ll n, ll k) {
ll ret = 1;
for (int i = 0; i < k; i++) {
ret = (ret * (n - i)) % MOD;
}
return ret;
}
ll modComb(ll n, ll k) {
ll a, b;
a = modPerm(n, k);
b = modPerm(k, k);
return (a * modInv(b)) % MOD;
}
int main() {
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << modComb(n - k + 1, i) * modComb(k - 1, i - 1) % MOD << endl;
}
return 0;
}
| [
"expression.operation.binary.add"
] | 797,438 | 797,439 | u651235280 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const ll MOD = 1e9 + 7;
// 繰り返し二乗法
ll modPow(ll x, ll a) {
if (a == 1)
return x;
// 指数aが奇数の時はx*x^(a-1)
if (a % 2)
return (x * modPow(x, a - 1)) % MOD;
// 指数aが偶数の時はx^(a/2)
ll t = modPow(x, a / 2);
return (t * t) % MOD;
}
// フェルマーの小定理からxのMOD-2乗を計算
ll modInv(ll x) { return modPow(x, MOD - 2); }
// kまでの階乗計算
ll modPerm(ll n, ll k) {
ll ret = 1;
for (int i = 0; i < k; i++) {
ret = (ret * (n - i)) % MOD;
}
return ret;
}
// 二項係数(n = 1e9, k = 1e7まで対応可能))
ll modComb(ll n, ll k) {
ll a, b;
// n - k + 1からnまでの積
a = modPerm(n, k);
// k!
b = modPerm(k, k);
return (a * modInv(b)) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << modComb(n - k + 1, i) * modComb(k - 1, i - 1) << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const ll MOD = 1e9 + 7;
// 繰り返し二乗法
ll modPow(ll x, ll a) {
if (a == 1)
return x;
// 指数aが奇数の時はx*x^(a-1)
if (a % 2)
return (x * modPow(x, a - 1)) % MOD;
// 指数aが偶数の時はx^(a/2)
ll t = modPow(x, a / 2);
return (t * t) % MOD;
}
// フェルマーの小定理からxのMOD-2乗を計算
ll modInv(ll x) { return modPow(x, MOD - 2); }
// kまでの階乗計算
ll modPerm(ll n, ll k) {
ll ret = 1;
for (int i = 0; i < k; i++) {
ret = (ret * (n - i)) % MOD;
}
return ret;
}
// 二項係数(n = 1e9, k = 1e7まで対応可能))
ll modComb(ll n, ll k) {
ll a, b;
// n - k + 1からnまでの積
a = modPerm(n, k);
// k!
b = modPerm(k, k);
return (a * modInv(b)) % MOD;
}
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << modComb(n - k + 1, i) * modComb(k - 1, i - 1) % MOD << endl;
}
}
| [
"expression.operation.binary.add"
] | 797,440 | 797,441 | u651235280 | cpp |
p02990 | #include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
ll factorial(ll a, ll b) {
ll ret = 1;
while (1) {
if (b == 0)
break;
ret = ret * a % mod;
--a;
--b;
}
return ret;
}
ll expo(ll a, ll b) {
ll ret = 1;
while (1) {
if (b == 0)
break;
if (b & 1LL)
ret = ret * a % mod;
a = a * a % mod;
b >>= 1LL;
}
return ret;
}
ll inv(ll a) { return expo(a, mod - 2); }
ll comb(ll a, ll b) {
// cout << factorial(a, b) << " " << factorial(b, b) << " " <<
// inv(factorial(b,b)) << endl;
return factorial(a, b) * inv(factorial(b, b)) % mod;
}
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; ++i) {
// cout << n-k+1 << " " << i << endl;
if (i == 1 || i == k) {
cout << comb(n - k + 1, i) << endl;
} else {
cout << comb(n - k + 1, i) * factorial(i, 1) % mod << endl;
}
}
return 0;
} | #include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
ll factorial(ll a, ll b) {
ll ret = 1;
while (1) {
if (b == 0)
break;
ret = ret * a % mod;
--a;
--b;
}
return ret;
}
ll expo(ll a, ll b) {
ll ret = 1;
while (1) {
if (b == 0)
break;
if (b & 1LL)
ret = ret * a % mod;
a = a * a % mod;
b >>= 1LL;
}
return ret;
}
ll inv(ll a) { return expo(a, mod - 2); }
ll comb(ll a, ll b) {
// cout << factorial(a, b) << " " << factorial(b, b) << " " <<
// inv(factorial(b,b)) << endl;
return factorial(a, b) * inv(factorial(b, b)) % mod;
}
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; ++i) {
// cout << n-k+1 << " " << i << endl;
if (i == 1 || i == k) {
cout << comb(n - k + 1, i) << endl;
} else {
cout << comb(n - k + 1, i) * comb(k - 1, i - 1) % mod << endl;
}
}
return 0;
} | [
"identifier.change",
"call.function.change",
"io.output.change"
] | 797,447 | 797,448 | u596311864 | cpp |
p02990 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 60;
const int mod = 1e9 + 7;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
combination comb(3000);
// K個をnグループに分ける
// グループに0個のものがあっても良い
mint f2(int k, int n) { return comb(k + n, n); }
// k個をnグループに分ける
// 各グループは1個以上ある
mint f(int k, int n) {
if (k < n)
return 0;
// if (k == 0 && n == 0) return 1;
if (n - 1 == 0)
return 1;
return f2(k - n, n - 1);
}
ll N, K;
int main() {
cin >> N >> K;
mint ans = 0;
for (int i = 1; i <= K; i++) {
mint blue = f(K, i);
mint red = 0;
red += f(N - K, i + 1);
red += f(N - K, i);
red += f(N - K, i);
red += f(N - K, i - 1);
ans = blue * red;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 60;
const int mod = 1e9 + 7;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
combination comb(3000);
// K個をnグループに分ける
// グループに0個のものがあっても良い
mint f2(int k, int n) { return comb(k + n, n); }
// k個をnグループに分ける
// 各グループは1個以上ある
mint f(int k, int n) {
if (k < n)
return 0;
// if (k == 0 && n == 0) return 1;
// if (n - 1 == 0) return 1;
if (n - k == 0)
return 1;
return f2(k - n, n - 1);
}
ll N, K;
int main() {
cin >> N >> K;
mint ans = 0;
for (int i = 1; i <= K; i++) {
mint blue = f(K, i);
mint red = 0;
red += f(N - K, i + 1);
red += f(N - K, i);
red += f(N - K, i);
red += f(N - K, i - 1);
// cout << blue << " " << red << endl;
ans = blue * red;
cout << ans << endl;
}
} | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change"
] | 797,451 | 797,452 | u455366471 | cpp |
p02990 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll RepeatSquaring(ll N, ll P, ll M) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = RepeatSquaring(N, P / 2, M);
return t * t % M;
}
return N * RepeatSquaring(N, P - 1, M);
}
int main() {
ll N, K;
cin >> N >> K;
ll R = N - K;
for (int i = 1; i <= K; i++) {
ll ans = 1;
ll rb = i - 1;
ll rn = R - i + 1;
if (rb > R) {
cout << 0 << endl;
continue;
}
ll k = K - 1;
for (int j = 1; j <= rb; j++) {
ans *= k;
ans %= mod;
k--;
}
for (int j = rb; j > 1; j--) {
ans *= RepeatSquaring(j, mod - 2, mod);
ans %= mod;
}
ll l = R + 1;
for (int j = 1; j <= i; j++) {
ans *= l;
ans %= mod;
l--;
}
for (int j = i; j > 1; j--) {
ans *= RepeatSquaring(j, mod - 2, mod);
ans %= mod;
}
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll RepeatSquaring(ll N, ll P, ll M) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = RepeatSquaring(N, P / 2, M);
return t * t % M;
}
return N * RepeatSquaring(N, P - 1, M) % M;
}
int main() {
ll N, K;
cin >> N >> K;
ll R = N - K;
for (int i = 1; i <= K; i++) {
ll ans = 1;
ll rb = i - 1;
ll rn = R - i + 1;
if (rb > R) {
cout << 0 << endl;
continue;
}
ll k = K - 1;
for (int j = 1; j <= rb; j++) {
ans *= k;
ans %= mod;
k--;
}
for (int j = rb; j > 1; j--) {
ans *= RepeatSquaring(j, mod - 2, mod);
ans %= mod;
}
ll l = R + 1;
for (int j = 1; j <= i; j++) {
ans *= l;
ans %= mod;
l--;
}
for (int j = i; j > 1; j--) {
ans *= RepeatSquaring(j, mod - 2, mod);
ans %= mod;
}
cout << ans << endl;
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,465 | 797,466 | u859566721 | cpp |
p02990 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 100010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int i, n, k, a, b;
cin >> n >> k;
n = n - k;
COMinit();
for (i = 0; i < k; i++) {
a = n - i;
b = 2 + i;
cout << COM(k - 1, i) * COM(n + 1, n - i) << endl;
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 100010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int i, n, k, a, b;
cin >> n >> k;
n = n - k;
COMinit();
for (i = 0; i < k; i++) {
a = n - i;
b = 2 + i;
cout << COM(k - 1, i) * COM(n + 1, n - i) % MOD << endl;
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,476 | 797,477 | u265187423 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
const ll INF = 1e18;
template <class T> void show(vector<T> v) {
for (int i = 0; i < v.size(); i++) {
cerr << v[i] << " ";
}
cerr << endl;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int MAX = 51000000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(int argc, char const *argv[]) {
int n, k;
cin >> n >> k;
COMinit();
ll ans = 0;
for (ll i = 1; i <= k; i++) {
cout << (COM(n - k + 1, i) % MOD) * (COM(k - 1, i - 1) % MOD) % MOD << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
const ll INF = 1e18;
template <class T> void show(vector<T> v) {
for (int i = 0; i < v.size(); i++) {
cerr << v[i] << " ";
}
cerr << endl;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int MAX = 10000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(int argc, char const *argv[]) {
int n, k;
cin >> n >> k;
COMinit();
ll ans = 0;
for (ll i = 1; i <= k; i++) {
cout << (COM(n - k + 1, i) % MOD) * (COM(k - 1, i - 1) % MOD) % MOD << endl;
}
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change"
] | 797,478 | 797,479 | u863279562 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
const ll INF = 1e18;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(int argc, char const *argv[]) {
COMinit();
int n, k;
cin >> n >> k;
for (int j = 1; j <= k; j++) {
cout << COM(k - 1, j - 1) * COM(n - k + 1, j) << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
const ll INF = 1e18;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(int argc, char const *argv[]) {
COMinit();
int n, k;
cin >> n >> k;
for (int j = 1; j <= k; j++) {
cout << COM(k - 1, j - 1) * COM(n - k + 1, j) % MOD << endl;
}
return 0;
}
| [
"expression.operation.binary.add"
] | 797,480 | 797,481 | u863279562 | cpp |
p02990 | #include <bits/stdc++.h>
#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N - 1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll, ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;
ll gcd(ll a, ll b) { // aとbの最大公約数を求める
if (a < b)
swap(a, b);
if (b <= 0)
return -1;
ll r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
ll lcm(ll a, ll b) { // aとbの最小公倍数を求める(gcd要)
return (a / gcd(a, b) * b);
}
/*nCk (mod MOD)の計算 BEGIN*/
// faccal -> n!, k!^(MOD-2)の計算(初期化)
// comb -> nCk (mod MOD)の計算
ll mlpow(ll x, ll p) { // x^p(long long)%MOD
ll tmp = 1;
if (p == 0)
return 1;
while (p != 0) {
if (p & 1)
tmp = tmp * x % MOD;
x = x * x % MOD;
p = p >> 1;
}
return tmp;
}
int facnum = 2005;
vl fac(facnum); // n!
vl facM2(facnum); // k!^(MOD-2)
void faccal(void) {
fac[0] = 1;
facM2[0] = 1;
for (ll i = 0; i < 2000; i++) {
fac[i + 1] = fac[i] * (i + 1) % MOD; // n!(mod M)
facM2[i + 1] = facM2[i] * mlpow(i + 1, MOD - 2) %
MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
}
}
ll comb(ll n, ll k) {
if (n == 0 && k == 0)
return 1;
if (n < k || n < 0)
return 0;
ll tmp = facM2[n - k] * facM2[k] % MOD;
return tmp * fac[n] % MOD; // nCk = n!*(k!)^(M-2)*((n-k)!)^(M-2)
}
/*nCk (mod MOD)の計算 END*/
int main() {
int N, K;
cin >> N >> K;
faccal();
rep1(i, K) {
ll ans = comb(K - 1, i - 1) * comb(N - K + 1, i);
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N - 1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll, ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;
ll gcd(ll a, ll b) { // aとbの最大公約数を求める
if (a < b)
swap(a, b);
if (b <= 0)
return -1;
ll r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
ll lcm(ll a, ll b) { // aとbの最小公倍数を求める(gcd要)
return (a / gcd(a, b) * b);
}
/*nCk (mod MOD)の計算 BEGIN*/
// faccal -> n!, k!^(MOD-2)の計算(初期化)
// comb -> nCk (mod MOD)の計算
ll mlpow(ll x, ll p) { // x^p(long long)%MOD
ll tmp = 1;
if (p == 0)
return 1;
while (p != 0) {
if (p & 1)
tmp = tmp * x % MOD;
x = x * x % MOD;
p = p >> 1;
}
return tmp;
}
int facnum = 2005;
vl fac(facnum); // n!
vl facM2(facnum); // k!^(MOD-2)
void faccal(void) {
fac[0] = 1;
facM2[0] = 1;
for (ll i = 0; i < 2000; i++) {
fac[i + 1] = fac[i] * (i + 1) % MOD; // n!(mod M)
facM2[i + 1] = facM2[i] * mlpow(i + 1, MOD - 2) %
MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
}
}
ll comb(ll n, ll k) {
if (n == 0 && k == 0)
return 1;
if (n < k || n < 0)
return 0;
ll tmp = facM2[n - k] * facM2[k] % MOD;
return tmp * fac[n] % MOD; // nCk = n!*(k!)^(M-2)*((n-k)!)^(M-2)
}
/*nCk (mod MOD)の計算 END*/
int main() {
int N, K;
cin >> N >> K;
faccal();
rep1(i, K) {
ll ans = comb(K - 1, i - 1) * comb(N - K + 1, i);
ans %= MOD;
cout << ans << endl;
}
return 0;
}
| [
"assignment.add"
] | 797,489 | 797,490 | u099619676 | cpp |
p02990 | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll modpow(ll a, ll n) {
if (n == 0)
return 1;
else if (n == 1)
return a;
else if (n % 2)
return a * modpow(a * a % mod, (n - 1) / 2) % mod;
else
return modpow(a * a % mod, n / 2);
}
ll modfact(ll na, ll nz) {
if (na == nz)
return 1;
else
return na * modfact(na - 1, nz) % mod;
}
ll modcomb(ll n, ll k) {
return modfact(n, k) * modpow(modfact(n - k, 0), mod - 2) % mod;
}
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; i++) {
if (i > (n + 1) / 2)
cout << 0 << endl;
else
cout << modcomb(n - k + 1, i) * modcomb(k - 1, i - 1) % mod << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll modpow(ll a, ll n) {
if (n == 0)
return 1;
else if (n == 1)
return a;
else if (n % 2)
return a * modpow(a * a % mod, (n - 1) / 2) % mod;
else
return modpow(a * a % mod, n / 2);
}
ll modfact(ll na, ll nz) {
if (na == nz)
return 1;
else
return na * modfact(na - 1, nz) % mod;
}
ll modcomb(ll n, ll k) {
return modfact(n, k) * modpow(modfact(n - k, 0), mod - 2) % mod;
}
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; i++) {
if (i > n - k + 1)
cout << 0 << endl;
else
cout << modcomb(n - k + 1, i) * modcomb(k - 1, i - 1) % mod << endl;
}
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 797,491 | 797,492 | u930561195 | cpp |
p02990 | #include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rep1(i, n) for (int i = 1; i <= (int)n; ++i)
#define all(a) begin(a), end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
bool chmin(int &a, int b) { return a > b ? (a = b, true) : false; }
bool chmax(int &a, int b) { return a < b ? (a = b, true) : false; }
int read() {
int a;
scanf("%lld", &a);
return a;
}
const int mod = 1e9 + 7;
ll inv[200010];
ll fac[200010], fac_inv[200010];
ll C(int n, int k) {
return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}
void comb_init() {
int N = 200005;
inv[1] = 1;
for (int i = 2; i <= N; ++i) {
inv[i] = mod - (mod / i) * inv[mod % i] % mod;
}
fac[0] = fac_inv[0] = 1;
for (int i = 1; i <= N; ++i) {
fac[i] = (fac[i - 1] * i) % mod;
fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
}
}
int N, K;
signed main() {
cin >> N >> K;
comb_init();
int r = N - K, b = K;
for (int i = 1; i <= b; ++i) {
if (r + 1 > i or b - 1 > i - 1)
cout << 0 << endl;
else
cout << C(r + 1, i) * C(b - 1, i - 1) % mod << endl;
}
}
| #include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rep1(i, n) for (int i = 1; i <= (int)n; ++i)
#define all(a) begin(a), end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
bool chmin(int &a, int b) { return a > b ? (a = b, true) : false; }
bool chmax(int &a, int b) { return a < b ? (a = b, true) : false; }
int read() {
int a;
scanf("%lld", &a);
return a;
}
const int mod = 1e9 + 7;
ll inv[200010];
ll fac[200010], fac_inv[200010];
ll C(int n, int k) {
return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}
void comb_init() {
int N = 200005;
inv[1] = 1;
for (int i = 2; i <= N; ++i) {
inv[i] = mod - (mod / i) * inv[mod % i] % mod;
}
fac[0] = fac_inv[0] = 1;
for (int i = 1; i <= N; ++i) {
fac[i] = (fac[i - 1] * i) % mod;
fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
}
}
int N, K;
signed main() {
cin >> N >> K;
comb_init();
int r = N - K, b = K;
for (int i = 1; i <= b; ++i) {
if (r + 1 < i or b - 1 < i - 1)
cout << 0 << endl;
else
cout << C(r + 1, i) * C(b - 1, i - 1) % mod << endl;
}
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 797,493 | 797,494 | u491256431 | cpp |
p02990 | #include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
using namespace std;
// 5 3
const int MAX = 2010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void initComb() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long comb(int n, int k) {
if (n < k) {
return 0;
}
if (n < 0 || k < 0) {
return 0;
}
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
initComb();
int n, k;
scanf("%d %d", &n, &k);
int r = (n - k);
for (ll i = 1; i <= k; i++) {
ll v1 = comb(r + 1, i);
ll v2 = comb(k - 1, i - 1);
cout << (v1 * v2) << endl;
}
}
| #include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
using namespace std;
// 5 3
const int MAX = 2010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void initComb() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long comb(int n, int k) {
if (n < k) {
return 0;
}
if (n < 0 || k < 0) {
return 0;
}
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
initComb();
int n, k;
scanf("%d %d", &n, &k);
int r = (n - k);
for (ll i = 1; i <= k; i++) {
ll v1 = comb(r + 1, i);
ll v2 = comb(k - 1, i - 1);
cout << (v1 * v2 % MOD) << endl;
}
}
| [
"expression.operation.binary.add"
] | 797,497 | 797,498 | u006576567 | cpp |
p02990 | #include <iostream>
#include <stdio.h>
//#include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define INF 1e9
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n) \
std::vector<type> c(n); \
for (auto &i : c) \
std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
// Combination MOD
const ll MOD = INF + 7;
vector<ll> fac(300000);
vector<ll> fac_inv(300000);
ll mpow(ll x, ll n) {
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % MOD;
x = x * x % MOD;
n = n >> 1;
}
return ans;
}
ll comb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0)
return 0;
ll tmp = fac_inv[a - b] * fac_inv[b] % MOD;
return tmp * fac[a] % MOD;
}
int main() {
int n, k;
cin >> n >> k;
fac[0] = 1;
fac_inv[0] = 1;
for (ll i = 0; i < 5000; i++) {
fac[i + 1] = fac[i] * (i + 1) % MOD;
fac_inv[i + 1] = fac_inv[i] * mpow(i + 1, MOD - 2) % MOD;
}
int l = n - k;
rep(i, k) {
ll res = comb(k - 1, i) % MOD * comb(2 + l + i - 1, l) % MOD;
cout << res << endl;
l--;
}
}
| #include <iostream>
#include <stdio.h>
//#include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define INF 1e9
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n) \
std::vector<type> c(n); \
for (auto &i : c) \
std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
// Combination MOD
const ll MOD = INF + 7;
vector<ll> fac(300000);
vector<ll> fac_inv(300000);
ll mpow(ll x, ll n) {
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % MOD;
x = x * x % MOD;
n = n >> 1;
}
return ans;
}
ll comb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
ll tmp = fac_inv[a - b] * fac_inv[b] % MOD;
return tmp * fac[a] % MOD;
}
int main() {
int n, k;
cin >> n >> k;
fac[0] = 1;
fac_inv[0] = 1;
for (ll i = 0; i < 300000; i++) {
fac[i + 1] = fac[i] * (i + 1) % MOD;
fac_inv[i + 1] = fac_inv[i] * mpow(i + 1, MOD - 2) % MOD;
}
int l = n - k;
rep(i, k) {
ll res = comb(k - 1, i) % MOD * comb(2 + l + i - 1, l) % MOD;
cout << res << endl;
l--;
}
}
| [
"control_flow.branch.if.condition.change",
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 797,510 | 797,509 | u516525290 | cpp |
p02990 | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
const long long MAX = 10000000;
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (long long i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
//そのまま計算すると負の値になるのでMODを足す
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(long long n, long long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
COMinit();
long long int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << COM(k - 1, k - i) * COM(i + n - k - (i - 1), n - k - (i - 1))
<< endl;
}
} | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
const long long MAX = 10000000;
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (long long i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
//そのまま計算すると負の値になるのでMODを足す
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(long long n, long long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
COMinit();
long long int n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cout << COM(k - 1, k - i) * COM(i + n - k - (i - 1), n - k - (i - 1)) % MOD
<< endl;
}
} | [
"expression.operation.binary.add"
] | 797,527 | 797,528 | u855866205 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (1000000007)
int arr[2010][2010] = {};
ll comb(ll n, ll r) {
if (n < 0 || r < 0)
cout << n << "," << r << endl;
if (arr[n][r] != 0)
return arr[n][r];
else if (r == 0) {
arr[n][r] = 1;
return arr[n][r];
} else if (r == 1) {
arr[n][r] = n;
return arr[n][r];
} else if (n <= r) {
arr[n][r] = 1;
return arr[n][r];
} else {
arr[n][r] = (comb(n - 1, r - 1) + comb(n - 1, r)) % MOD;
return arr[n][r];
}
}
int main() {
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
if (n - k + 1 < i)
cout << -1 << endl;
else
cout << (comb(n - k + 1, i) * comb(k - 1, i - 1)) % MOD << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (1000000007)
int arr[2010][2010] = {};
ll comb(ll n, ll r) {
if (n < 0 || r < 0)
cout << n << "," << r << endl;
if (arr[n][r] != 0)
return arr[n][r];
else if (r == 0) {
arr[n][r] = 1;
return arr[n][r];
} else if (r == 1) {
arr[n][r] = n;
return arr[n][r];
} else if (n <= r) {
arr[n][r] = 1;
return arr[n][r];
} else {
arr[n][r] = (comb(n - 1, r - 1) + comb(n - 1, r)) % MOD;
return arr[n][r];
}
}
int main() {
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
if (n - k + 1 < i)
cout << 0 << endl;
else
cout << (comb(n - k + 1, i) * comb(k - 1, i - 1)) % MOD << endl;
}
}
| [
"literal.number.change",
"io.output.change"
] | 797,541 | 797,542 | u218759384 | cpp |
p02990 | #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int MAX = 510000; // nCrのr
const int MOD = 1000000007;
typedef long long ll;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 1; i <= K; ++i) {
cout << COM(N - K + 1, i) * COM(K - 1, i - 1) << endl;
}
}
| #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int MAX = 510000; // nCrのr
const int MOD = 1000000007;
typedef long long ll;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 1; i <= K; ++i) {
cout << (COM(N - K + 1, i) * COM(K - 1, i - 1) + MOD) % MOD << endl;
}
}
| [
"expression.operation.binary.add"
] | 797,545 | 797,546 | u952081880 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
struct cww {
cww() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// N-K+1 C i * K-1 C i-1
int main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 1; i <= K; i++) {
int ans = COM(K - 1, i - 1) * COM(N - K + 1, i);
ans %= MOD;
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
struct cww {
cww() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// N-K+1 C i * K-1 C i-1
int main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 1; i <= K; i++) {
long long ans = COM(K - 1, i - 1) * COM(N - K + 1, i);
ans %= MOD;
cout << ans << endl;
}
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 797,551 | 797,552 | u151005508 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll C[2010][2010];
ll mod = 1e9 + 7;
void init() {
C[0][0] = 1;
C[1][0] = 1;
C[1][1] = 1;
for (int i = 2; i < 2010; ++i) {
C[i][0] = 1;
for (int j = 1; j < 2010; ++j) {
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
}
}
}
int main() {
init();
int n, k;
cin >> n >> k;
int b = k;
int r = n - k;
for (int i = 1; i <= k; ++i) {
ll prob = C[r + 1][i] * C[b - 1][i - 1];
cout << prob << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll C[2010][2010];
ll mod = 1e9 + 7;
void init() {
C[0][0] = 1;
C[1][0] = 1;
C[1][1] = 1;
for (int i = 2; i < 2010; ++i) {
C[i][0] = 1;
for (int j = 1; j < 2010; ++j) {
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
}
}
}
int main() {
init();
int n, k;
cin >> n >> k;
int b = k;
int r = n - k;
for (int i = 1; i <= k; ++i) {
ll prob = (C[r + 1][i] * C[b - 1][i - 1]) % mod;
cout << prob << endl;
}
} | [
"assignment.change"
] | 797,553 | 797,554 | u808092084 | cpp |
p02990 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-14)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
using Graph = vector<VE>;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &m) {
os << m.x;
return os;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} com(200010);
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
class UnionFind {
public:
vector<ll> par;
vector<ll> siz;
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
// Member Function
// Find
ll root(ll x) {
while (par[x] != x) {
x = par[x] = par[par[x]];
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { return root(x) == root(y); }
ll size(ll x) { return siz[root(x)]; }
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a * b / g;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
mint POW(mint n, int p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
mint t = POW(n, p / 2);
return t * t;
}
return n * POW(n, p - 1);
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(15);
int n, k;
cin >> n >> k;
rep(i, k) { cout << com(n - k - 1, i + 1) * com(k - 1, i) << endl; }
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-14)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
using Graph = vector<VE>;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &m) {
os << m.x;
return os;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} com(200010);
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
class UnionFind {
public:
vector<ll> par;
vector<ll> siz;
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
// Member Function
// Find
ll root(ll x) {
while (par[x] != x) {
x = par[x] = par[par[x]];
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { return root(x) == root(y); }
ll size(ll x) { return siz[root(x)]; }
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a * b / g;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
mint POW(mint n, int p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
mint t = POW(n, p / 2);
return t * t;
}
return n * POW(n, p - 1);
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(15);
int n, k;
cin >> n >> k;
rep(i, k) { cout << com(n - k + 1, i + 1) * com(k - 1, i) << endl; }
return 0;
} | [
"misc.opposites",
"expression.operator.arithmetic.change",
"io.output.change"
] | 797,562 | 797,563 | u809967037 | cpp |
p02990 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-14)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
using Graph = vector<VE>;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &m) {
os << m.x;
return os;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} com(200010);
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
class UnionFind {
public:
vector<ll> par;
vector<ll> siz;
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
// Member Function
// Find
ll root(ll x) {
while (par[x] != x) {
x = par[x] = par[par[x]];
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { return root(x) == root(y); }
ll size(ll x) { return siz[root(x)]; }
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a * b / g;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
mint POW(mint n, int p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
mint t = POW(n, p / 2);
return t * t;
}
return n * POW(n, p - 1);
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(15);
int n, k;
cin >> n >> k;
rep(i, k) { cout << com(n + k - 1, i + 1) * com(k - 1, i) << endl; }
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-14)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
using Graph = vector<VE>;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
friend ostream &operator<<(ostream &os, const mint &m) {
os << m.x;
return os;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} com(200010);
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
class UnionFind {
public:
vector<ll> par;
vector<ll> siz;
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i;
}
// Member Function
// Find
ll root(ll x) {
while (par[x] != x) {
x = par[x] = par[par[x]];
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { return root(x) == root(y); }
ll size(ll x) { return siz[root(x)]; }
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a * b / g;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
mint POW(mint n, int p) {
if (p == 0)
return 1;
if (p % 2 == 0) {
mint t = POW(n, p / 2);
return t * t;
}
return n * POW(n, p - 1);
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(15);
int n, k;
cin >> n >> k;
rep(i, k) { cout << com(n - k + 1, i + 1) * com(k - 1, i) << endl; }
return 0;
} | [
"expression.operation.binary.remove"
] | 797,564 | 797,563 | u809967037 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll>;
#define all(v) v.begin(), v.end()
#define MAX 2020
const ll MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
COMinit();
ll ans = 0;
//赤の間からi箇所選ぶ
for (ll i = 1; i <= K; ++i) {
cout << COM(N - K + 1, i) * COM(K - 1, i - 1) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll>;
#define all(v) v.begin(), v.end()
#define MAX 2020
const ll MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
COMinit();
ll ans = 0;
//赤の間からi箇所選ぶ
for (ll i = 1; i <= K; ++i) {
cout << COM(N - K + 1, i) * COM(K - 1, i - 1) % MOD << endl;
}
} | [
"expression.operation.binary.add"
] | 797,567 | 797,568 | u883725898 | cpp |
p02990 |
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define SHOW_VECTOR(v) \
{ \
std::cerr << #v << "\t:"; \
for (const auto &xxx : v) { \
std::cerr << xxx << " "; \
} \
std::cerr << "\n"; \
}
#define SHOW_MAP(v) \
{ \
std::cerr << #v << endl; \
for (const auto &xxx : v) { \
std::cerr << xxx.first << " " << xxx.second << "\n"; \
} \
}
using LL = long long;
//~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~
constexpr LL mod = 1e9 + 7;
constexpr LL MAX = 6000;
LL fac[MAX];
LL inv[MAX];
LL pow_mod(LL n, LL p) {
LL ret = 1;
while (p > 0) {
if (p & 1)
ret = (ret * n) % mod;
n = (n * n) % mod;
p >>= 1;
}
return ret;
}
void setup() {
fac[0] = fac[1] = 1;
inv[0] = pow_mod(fac[0], mod - 2);
inv[1] = pow_mod(fac[1], mod - 2);
for (LL i = 2; i <= MAX - 2; i++) {
fac[i] = fac[i - 1] * i;
fac[i] %= mod;
inv[i] = pow_mod(fac[i], mod - 2);
}
}
LL comb(LL n, LL r) { return fac[n] * inv[r] % mod * inv[n - r] % mod; }
LL f2(LL n, LL k) { return comb(n + k - 1, k - 1); }
LL f(LL n, LL k) {
if (n < k)
return 0;
if (n == 0 && k == 0)
return 0;
if (k < 1)
return 0;
return f2(n - k, k);
}
int main() {
LL N, K;
cin >> N >> K;
setup();
for (LL k = 1; k <= K; k++) {
LL blue = f(K, k);
LL red = 0;
red += f(N - K, k - 1);
red %= mod;
red += f(N - K, k);
red %= mod;
red += f(N - K, k);
red %= mod;
red += f(N - K, k + 1);
red %= mod;
LL ans = (blue * red) % mod;
cout << ans << endl;
}
}
|
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define SHOW_VECTOR(v) \
{ \
std::cerr << #v << "\t:"; \
for (const auto &xxx : v) { \
std::cerr << xxx << " "; \
} \
std::cerr << "\n"; \
}
#define SHOW_MAP(v) \
{ \
std::cerr << #v << endl; \
for (const auto &xxx : v) { \
std::cerr << xxx.first << " " << xxx.second << "\n"; \
} \
}
using LL = long long;
//~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~
constexpr LL mod = 1e9 + 7;
constexpr LL MAX = 6000;
LL fac[MAX];
LL inv[MAX];
LL pow_mod(LL n, LL p) {
LL ret = 1;
while (p > 0) {
if (p & 1)
ret = (ret * n) % mod;
n = (n * n) % mod;
p >>= 1;
}
return ret;
}
void setup() {
fac[0] = fac[1] = 1;
inv[0] = pow_mod(fac[0], mod - 2);
inv[1] = pow_mod(fac[1], mod - 2);
for (LL i = 2; i <= MAX - 2; i++) {
fac[i] = fac[i - 1] * i;
fac[i] %= mod;
inv[i] = pow_mod(fac[i], mod - 2);
}
}
LL comb(LL n, LL r) { return fac[n] * inv[r] % mod * inv[n - r] % mod; }
LL f2(LL n, LL k) { return comb(n + k - 1, k - 1); }
LL f(LL n, LL k) {
if (n < k)
return 0;
if (n == 0 && k == 0)
return 1;
if (k < 1)
return 0;
return f2(n - k, k);
}
int main() {
LL N, K;
cin >> N >> K;
setup();
for (LL k = 1; k <= K; k++) {
LL blue = f(K, k);
LL red = 0;
red += f(N - K, k - 1);
red %= mod;
red += f(N - K, k);
red %= mod;
red += f(N - K, k);
red %= mod;
red += f(N - K, k + 1);
red %= mod;
LL ans = (blue * red) % mod;
cout << ans << endl;
}
}
| [
"literal.number.change",
"function.return_value.change"
] | 797,576 | 797,577 | u259053514 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
struct Combination {
vector<long long> inv, finv, fac;
Combination(int n, int kmax) : inv(kmax + 1), finv(kmax + 1), fac(kmax) {
if (kmax >= 1) {
inv.at(1) = 1;
finv.at(1) = 1;
fac.at(0) = n;
}
for (int i = 2; i <= kmax; i++)
inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
for (int i = 2; i <= kmax; i++)
finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
for (int i = 1; i < kmax; i++)
fac.at(i) = fac.at(i - 1) * (n - i) % MOD;
}
int comb(int k) { return (k ? fac.at(k - 1) * finv.at(k) % MOD : 1); }
};
int main() {
int n, k;
cin >> n >> k;
Combination c(k - 1, k - 1), d(n - k + 1, k);
for (int i = k - 1; i >= 0; i--) {
cout << (c.comb(i) * d.comb(k - i)) % MOD << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
struct Combination {
vector<long long> inv, finv, fac;
Combination(int n, int kmax) : inv(kmax + 1), finv(kmax + 1), fac(kmax) {
if (kmax >= 1) {
inv.at(1) = 1;
finv.at(1) = 1;
fac.at(0) = n;
}
for (int i = 2; i <= kmax; i++)
inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
for (int i = 2; i <= kmax; i++)
finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
for (int i = 1; i < kmax; i++)
fac.at(i) = fac.at(i - 1) * (n - i) % MOD;
}
ll comb(int k) { return (k ? fac.at(k - 1) * finv.at(k) % MOD : 1); }
};
int main() {
int n, k;
cin >> n >> k;
Combination c(k - 1, k - 1), d(n - k + 1, k);
for (int i = k - 1; i >= 0; i--) {
cout << (c.comb(i) * d.comb(k - i)) % MOD << endl;
}
} | [] | 797,578 | 797,579 | u168860135 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007LL;
ll pow(ll a, ll n, ll m) {
ll ret = 1LL;
for (; n > 0LL; n >>= 1LL, a = a * a % m) {
if (n % 2LL == 1LL) {
ret = ret * a % m;
}
}
return ret;
}
ll combination(ll x, ll y) {
if (y > x)
return 0LL;
ll c = 1LL;
for (ll i = 0LL; i < y; i++) {
c *= (x - i) % mod;
c %= mod;
c *= pow(i + 1, mod - 2, mod);
c %= mod;
}
return c;
}
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 1LL; i < K; i++) {
cout << ((combination(K - 1, i - 1) * combination(N - K + 1, i)) % mod)
<< endl;
}
} | #include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007LL;
ll pow(ll a, ll n, ll m) {
ll ret = 1LL;
for (; n > 0LL; n >>= 1LL, a = a * a % m) {
if (n % 2LL == 1LL) {
ret = ret * a % m;
}
}
return ret;
}
ll combination(ll x, ll y) {
if (y > x)
return 0LL;
ll c = 1LL;
for (ll i = 0LL; i < y; i++) {
c *= (x - i) % mod;
c %= mod;
c *= pow(i + 1, mod - 2, mod);
c %= mod;
}
return c;
}
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 1LL; i <= K; i++) {
cout << ((combination(K - 1, i - 1) * combination(N - K + 1, i)) % mod)
<< endl;
}
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 797,584 | 797,585 | u787139585 | cpp |
p02990 | /**
* author: rishabh_sethi
**/
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mem(x, val) memset(x, val, sizeof(x))
#define mk make_pair
#define f(i, n) for (i = 0; i < n; i++)
#define f1(i, n) for (i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define upp(v, val) upper_bound(v.begin(), v.end(), val)
#define lower(v, val) lower_bound(v.begin(), v.end(), val)
#define make_unique(x) \
sort(all((x))); \
(x).resize(unique(all((x))) - (x).begin())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x, y, z) \
cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " \
<< z << endl
#define dbg4(x, y, z, q) \
cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " \
<< z << ", " << #q << " = " << q << endl
#define jaldi_chal() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define S second
#define F first
#define fm(it, m) for (it = m.begin(); it != m.end(); it++)
#define ct_set(n) __builtin_popcount(n) // count no of set bits
#define INF 0x3f3f3f3f
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265 // acosl(-1)
#define precision cout << setprecision(15)
#define print_arr(a, n) \
for (int i = 0; i < n; i++) \
cout << a[i] << " ";
#define print_vec(v) \
for (int i = 0; i < v.size(); i++) \
cout << v[i] << " ";
// vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end());
using namespace std;
// for ordered set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
// v.resize(unique(v.begin(), v.end()) - v.begin()); // for unique elements in
// sorted vector fflush(stdout); // after every output
// Using 128 bit integers
/*
std::string toString(__int128 num) {
std::string str;
do {
int digit = num % 10;
str = std::to_string(digit) + str;
num = (num - digit) / 10;
} while (num != 0);
return str;
}
int main() {
__int128_t x;
string s;
cin >> s;
x = (stoll)(s);
__int128_t ans = x * x * x;
cout << toString(ans);
}
*/
bool isPrime(ll n) {
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (ll i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
ll ans = (a * b) / g;
return ans;
}
ll add(ll a, ll b) {
a += b;
if (a >= mod)
a -= mod;
return a;
}
ll sub(ll a, ll b) {
a -= b;
if (a < 0) {
a += mod;
}
return a;
}
ll mul(ll a, ll b) { return (a * b) % mod; }
vector<ll> primes;
bool prime[10005];
void seive() {
mem(prime, 1);
prime[0] = 0;
prime[1] = 0;
for (ll i = 2; i <= 10000; i++) {
if (prime[i] == 1) {
for (ll j = i * i; j <= 10000; j += i)
prime[j] = 0;
}
}
}
ll power(ll a, ll b) {
ll ans = 1;
while (b > 0) {
if (b % 2 == 1)
ans = (ans % mod * a % mod) % mod;
a = (a * a) % mod;
b = b / 2;
}
return ans;
}
template <typename T> std::string NumberToString(T Number) {
std::ostringstream ss;
ss << Number;
return ss.str();
}
string num_to_bits(ll n) {
string ans = "";
while (n) {
ans += (n % 2) + '0';
n /= 2;
}
reverse(all(ans));
return ans;
}
ll bits_to_num(string s) {
ll ans = 0;
for (ll i = 0; i < s.size(); i++) {
ll x = s.size() - i - 1;
ll val = pow(2LL, x);
if (s[i] == '1') {
ans = ans + val;
}
}
return ans;
}
ll gcdExtended(ll a, ll b, ll *x, ll *y);
ll modInverse(ll b, ll m) {
ll x, y;
ll g = gcdExtended(b, m, &x, &y);
if (g != 1)
return -1;
return (x % m + m) % m;
}
// Function to compute a/b under modlo m
ll modDivide(ll a, ll b, ll m) {
a = a % m;
ll inv = modInverse(b, m);
// if (inv == -1)
// cout << "Division not defined";
// else
// cout << "Result of division is " << (inv * a) % m;
return (inv * a) % m;
}
ll gcdExtended(ll a, ll b, ll *x, ll *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
ll x1, y1;
ll gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
// To call for modulo division (a / b) % m : modDivide(a, b, m);
/* This will store divisors of the number from 1 to n
for(i = 1; i <= n; i++) {
for(j = i; j <= n; j += i) {
v[j].pb(i);
}
}
*/
ll fact[2005];
void factorials() {
fact[0] = 1;
for (ll i = 1; i <= 2002; i++) {
fact[i] = (i * fact[i - 1]) % mod;
}
}
ll nCr(ll n, ll r) {
if (r > n) {
return 0;
}
ll result = fact[n];
result = modDivide(result, fact[r], mod);
return modDivide(result, fact[n - r], mod);
}
void solve() {
factorials();
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; i++) {
cout << (nCr(n - k + 1, i) * nCr(k - 1, i - 1)) << endl;
}
}
int main() {
jaldi_chal()
// freopen("input.txt", "r" , stdin);
// freopen("output.txt", "w", stdout);
// seive();
// for(int i = 2; i <= 10000; i++) {
// if(prime[i])
// primes.pb(i);
// }
bool codechef = 0;
ll t = 1;
if (codechef) {
cin >> t;
}
for (ll i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
solve();
}
return 0;
} | /**
* author: rishabh_sethi
**/
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mem(x, val) memset(x, val, sizeof(x))
#define mk make_pair
#define f(i, n) for (i = 0; i < n; i++)
#define f1(i, n) for (i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define upp(v, val) upper_bound(v.begin(), v.end(), val)
#define lower(v, val) lower_bound(v.begin(), v.end(), val)
#define make_unique(x) \
sort(all((x))); \
(x).resize(unique(all((x))) - (x).begin())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x, y, z) \
cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " \
<< z << endl
#define dbg4(x, y, z, q) \
cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " \
<< z << ", " << #q << " = " << q << endl
#define jaldi_chal() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define S second
#define F first
#define fm(it, m) for (it = m.begin(); it != m.end(); it++)
#define ct_set(n) __builtin_popcount(n) // count no of set bits
#define INF 0x3f3f3f3f
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265 // acosl(-1)
#define precision cout << setprecision(15)
#define print_arr(a, n) \
for (int i = 0; i < n; i++) \
cout << a[i] << " ";
#define print_vec(v) \
for (int i = 0; i < v.size(); i++) \
cout << v[i] << " ";
// vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end());
using namespace std;
// for ordered set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
tree_order_statistics_node_update>
// v.resize(unique(v.begin(), v.end()) - v.begin()); // for unique elements in
// sorted vector fflush(stdout); // after every output
// Using 128 bit integers
/*
std::string toString(__int128 num) {
std::string str;
do {
int digit = num % 10;
str = std::to_string(digit) + str;
num = (num - digit) / 10;
} while (num != 0);
return str;
}
int main() {
__int128_t x;
string s;
cin >> s;
x = (stoll)(s);
__int128_t ans = x * x * x;
cout << toString(ans);
}
*/
bool isPrime(ll n) {
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (ll i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
ll ans = (a * b) / g;
return ans;
}
ll add(ll a, ll b) {
a += b;
if (a >= mod)
a -= mod;
return a;
}
ll sub(ll a, ll b) {
a -= b;
if (a < 0) {
a += mod;
}
return a;
}
ll mul(ll a, ll b) { return (a * b) % mod; }
vector<ll> primes;
bool prime[10005];
void seive() {
mem(prime, 1);
prime[0] = 0;
prime[1] = 0;
for (ll i = 2; i <= 10000; i++) {
if (prime[i] == 1) {
for (ll j = i * i; j <= 10000; j += i)
prime[j] = 0;
}
}
}
ll power(ll a, ll b) {
ll ans = 1;
while (b > 0) {
if (b % 2 == 1)
ans = (ans % mod * a % mod) % mod;
a = (a * a) % mod;
b = b / 2;
}
return ans;
}
template <typename T> std::string NumberToString(T Number) {
std::ostringstream ss;
ss << Number;
return ss.str();
}
string num_to_bits(ll n) {
string ans = "";
while (n) {
ans += (n % 2) + '0';
n /= 2;
}
reverse(all(ans));
return ans;
}
ll bits_to_num(string s) {
ll ans = 0;
for (ll i = 0; i < s.size(); i++) {
ll x = s.size() - i - 1;
ll val = pow(2LL, x);
if (s[i] == '1') {
ans = ans + val;
}
}
return ans;
}
ll gcdExtended(ll a, ll b, ll *x, ll *y);
ll modInverse(ll b, ll m) {
ll x, y;
ll g = gcdExtended(b, m, &x, &y);
if (g != 1)
return -1;
return (x % m + m) % m;
}
// Function to compute a/b under modlo m
ll modDivide(ll a, ll b, ll m) {
a = a % m;
ll inv = modInverse(b, m);
// if (inv == -1)
// cout << "Division not defined";
// else
// cout << "Result of division is " << (inv * a) % m;
return (inv * a) % m;
}
ll gcdExtended(ll a, ll b, ll *x, ll *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
ll x1, y1;
ll gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
// To call for modulo division (a / b) % m : modDivide(a, b, m);
/* This will store divisors of the number from 1 to n
for(i = 1; i <= n; i++) {
for(j = i; j <= n; j += i) {
v[j].pb(i);
}
}
*/
ll fact[2005];
void factorials() {
fact[0] = 1;
for (ll i = 1; i <= 2002; i++) {
fact[i] = (i * fact[i - 1]) % mod;
}
}
ll nCr(ll n, ll r) {
if (r > n) {
return 0;
}
ll result = fact[n];
result = modDivide(result, fact[r], mod);
return modDivide(result, fact[n - r], mod);
}
void solve() {
factorials();
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; i++) {
cout << (nCr(n - k + 1, i) * nCr(k - 1, i - 1)) % mod << endl;
}
}
int main() {
jaldi_chal()
// freopen("input.txt", "r" , stdin);
// freopen("output.txt", "w", stdout);
// seive();
// for(int i = 2; i <= 10000; i++) {
// if(prime[i])
// primes.pb(i);
// }
bool codechef = 0;
ll t = 1;
if (codechef) {
cin >> t;
}
for (ll i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
solve();
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,592 | 797,593 | u097326875 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back
template <typename T> void printV(vector<T> A) {
if (A.empty())
cerr << "EMTPY\n";
else {
cerr << "[";
for (int i = 0; i < A.size() - 1; ++i) {
cerr << A[i] << ", ";
}
if (A.size())
cerr << A.back() << "]\n";
}
}
template <typename T> void printVV(vector<vector<T>> A) {
cerr << "[";
for (auto v : A) {
printV<T>(v);
}
cerr << "]";
}
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
const int MAXN = 2002;
ll fact[MAXN], inv[MAXN], finv[MAXN];
const ll mod = 1e9 + 7;
ll calc(ll n, ll i, ll k) {
ll r = n - k + 1;
if (r - i < 0)
return 1;
ll x = (((fact[r] * finv[r - i]) % mod) * finv[i]) % mod;
ll y = (((fact[k - 1] * finv[k - 1 - (i - 1)]) % mod) * finv[i - 1]) % mod;
return (x * y) % mod;
}
int main(int argc, char **argv) {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, k;
cin >> n >> k;
fact[0] = fact[1] = 1;
for (int i = 2; i < MAXN; ++i) {
fact[i] = (i * fact[i - 1]) % mod;
}
inv[0] = inv[1] = 1;
for (int i = 2; i < MAXN; ++i) {
inv[i] = (inv[mod % i] * (mod - mod / i)) % mod;
}
finv[0] = finv[1] = 1;
for (int i = 2; i < MAXN; ++i) {
finv[i] = (finv[i - 1] * inv[i]) % mod;
}
for (ll i = 1; i <= k; ++i) {
cout << calc(n, i, k) << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back
template <typename T> void printV(vector<T> A) {
if (A.empty())
cerr << "EMTPY\n";
else {
cerr << "[";
for (int i = 0; i < A.size() - 1; ++i) {
cerr << A[i] << ", ";
}
if (A.size())
cerr << A.back() << "]\n";
}
}
template <typename T> void printVV(vector<vector<T>> A) {
cerr << "[";
for (auto v : A) {
printV<T>(v);
}
cerr << "]";
}
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
const int MAXN = 2002;
ll fact[MAXN], inv[MAXN], finv[MAXN];
const ll mod = 1e9 + 7;
ll calc(ll n, ll i, ll k) {
ll r = n - k + 1;
if (r - i < 0)
return 0;
ll x = (((fact[r] * finv[r - i]) % mod) * finv[i]) % mod;
ll y = (((fact[k - 1] * finv[k - 1 - (i - 1)]) % mod) * finv[i - 1]) % mod;
return (x * y) % mod;
}
int main(int argc, char **argv) {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, k;
cin >> n >> k;
fact[0] = fact[1] = 1;
for (int i = 2; i < MAXN; ++i) {
fact[i] = (i * fact[i - 1]) % mod;
}
inv[0] = inv[1] = 1;
for (int i = 2; i < MAXN; ++i) {
inv[i] = (inv[mod % i] * (mod - mod / i)) % mod;
}
finv[0] = finv[1] = 1;
for (int i = 2; i < MAXN; ++i) {
finv[i] = (finv[i - 1] * inv[i]) % mod;
}
for (ll i = 1; i <= k; ++i) {
cout << calc(n, i, k) << endl;
}
return 0;
}
| [
"literal.number.change",
"function.return_value.change"
] | 797,594 | 797,595 | u825443083 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
struct Combination {
vector<vector<int>> memo;
Combination(int x) {
memo.resize(x + 1);
for (int i = 0; i <= x; i++)
memo[i].resize(x + 1, 0);
}
int RetCombination(int n, int r, int mod) {
if (n < 0 || r < 0 || n < r) {
return 0;
}
if (memo[n][r] != 0)
return memo[n][r];
if (r == 0 || n == r || n == 0) {
return memo[n][r] = 1;
}
int k = RetCombination(n - 1, r - 1, mod) % mod;
int l = RetCombination(n - 1, r, mod) % mod;
memo[n - 1][r - 1] = k, memo[n - 1][r] = l;
return memo[n][r] = (k + l) % mod;
}
};
long long longpow(long long n, long long a, long long mod) {
if (a == 0)
return 1;
if (a == 1)
return n % mod;
if (a % 2 == 1)
return (n * longpow(n, a - 1, mod)) % mod;
ll t = longpow(n, a / 2, mod) % mod;
return (t * t) % mod;
}
int main() {
int N, K;
cin >> N >> K;
Combination cm(2010);
for (int i = 1; i <= K; ++i) {
cout << (cm.RetCombination(K - 1, i - 1, MOD) *
cm.RetCombination(N - K + 1, i, MOD) +
MOD) %
MOD
<< endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
struct Combination {
vector<vector<ll>> memo;
Combination(int x) {
memo.resize(x + 1);
for (int i = 0; i <= x; i++)
memo[i].resize(x + 1, 0);
}
ll RetCombination(int n, int r, int mod) {
if (n < 0 || r < 0 || n < r) {
return 0;
}
if (memo[n][r] != 0)
return memo[n][r];
if (r == 0 || n == r || n == 0) {
return memo[n][r] = 1;
}
ll k = RetCombination(n - 1, r - 1, mod) % mod;
ll l = RetCombination(n - 1, r, mod) % mod;
memo[n - 1][r - 1] = k, memo[n - 1][r] = l;
return memo[n][r] = (k + l) % mod;
}
};
long long longpow(long long n, long long a, long long mod) {
if (a == 0)
return 1;
if (a == 1)
return n % mod;
if (a % 2 == 1)
return (n * longpow(n, a - 1, mod)) % mod;
ll t = longpow(n, a / 2, mod) % mod;
return (t * t) % mod;
}
int main() {
int N, K;
cin >> N >> K;
Combination cm(2010);
for (int i = 1; i <= K; ++i) {
cout << (cm.RetCombination(K - 1, i - 1, MOD) *
cm.RetCombination(N - K + 1, i, MOD) +
MOD) %
MOD
<< endl;
}
} | [
"variable_declaration.type.change"
] | 797,602 | 797,603 | u893239355 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
struct Combination {
vector<vector<int>> memo;
Combination(int x) {
memo.resize(x + 1);
for (int i = 0; i <= x; i++)
memo[i].resize(x + 1, 0);
}
int RetCombination(int n, int r, int mod) {
if (n < 0 || r < 0 || n < r) {
return 0;
}
if (memo[n][r] != 0)
return memo[n][r];
if (r == 0 || n == r || n == 0) {
return memo[n][r] = 1;
}
int k = RetCombination(n - 1, r - 1, mod) % mod;
int l = RetCombination(n - 1, r, mod) % mod;
memo[n - 1][r - 1] = k, memo[n - 1][r] = l;
return memo[n][r] = (k + l) % mod;
}
};
long long longpow(long long n, long long a, long long mod) {
if (a == 0)
return 1;
if (a == 1)
return n % mod;
if (a % 2 == 1)
return (n * longpow(n, a - 1, mod)) % mod;
ll t = longpow(n, a / 2, mod) % mod;
return (t * t) % mod;
}
int main() {
int N, K;
cin >> N >> K;
Combination cm(2010);
for (int i = 1; i <= K; ++i) {
cout << (cm.RetCombination(K - 1, i - 1, MOD) *
cm.RetCombination(N - K + 1, i, MOD)) %
MOD
<< endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
struct Combination {
vector<vector<ll>> memo;
Combination(int x) {
memo.resize(x + 1);
for (int i = 0; i <= x; i++)
memo[i].resize(x + 1, 0);
}
ll RetCombination(int n, int r, int mod) {
if (n < 0 || r < 0 || n < r) {
return 0;
}
if (memo[n][r] != 0)
return memo[n][r];
if (r == 0 || n == r || n == 0) {
return memo[n][r] = 1;
}
ll k = RetCombination(n - 1, r - 1, mod) % mod;
ll l = RetCombination(n - 1, r, mod) % mod;
memo[n - 1][r - 1] = k, memo[n - 1][r] = l;
return memo[n][r] = (k + l) % mod;
}
};
long long longpow(long long n, long long a, long long mod) {
if (a == 0)
return 1;
if (a == 1)
return n % mod;
if (a % 2 == 1)
return (n * longpow(n, a - 1, mod)) % mod;
ll t = longpow(n, a / 2, mod) % mod;
return (t * t) % mod;
}
int main() {
int N, K;
cin >> N >> K;
Combination cm(2010);
for (int i = 1; i <= K; ++i) {
cout << (cm.RetCombination(K - 1, i - 1, MOD) *
cm.RetCombination(N - K + 1, i, MOD) +
MOD) %
MOD
<< endl;
}
} | [
"variable_declaration.type.change"
] | 797,604 | 797,603 | u893239355 | cpp |
p02990 | #include <bits/stdc++.h>
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(), a.end()
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
ll C[2010][2010];
int main() {
memset(C, 0, sizeof C);
rep(i, 2010) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i)
C[i][j] = 1;
else {
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
C[i][j] %= mod;
}
}
}
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
if (n - k + 1 < i)
cout << 0 << endl;
else
cout << C[n - k + 1][i] * C[k - 1][i - 1] << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(), a.end()
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
ll C[2010][2010];
int main() {
memset(C, 0, sizeof C);
rep(i, 2010) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i)
C[i][j] = 1;
else {
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
C[i][j] %= mod;
}
}
}
ll n, k;
cin >> n >> k;
for (int i = 1; i <= k; i++) {
if (n - k + 1 < i)
cout << 0 << endl;
else
cout << C[n - k + 1][i] * C[k - 1][i - 1] % mod << endl;
}
return 0;
} | [
"expression.operation.binary.add"
] | 797,609 | 797,610 | u641900703 | cpp |
p02990 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
mint f2(int x, int y) {
combination c(x + y - 1);
return c(x + y - 1, y - 1);
}
mint f(int x, int y) { return f2(x - y, y); }
int main() {
int n, k;
cin >> n >> k;
combination c(n - k + 1);
for (int i = 1; i <= n; i++) {
mint red = c(n - k + 1, i);
mint blue = f(k, i);
mint ans = red * blue;
cout << ans.x << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
mint f2(int x, int y) {
combination c(x + y - 1);
return c(x + y - 1, y - 1);
}
mint f(int x, int y) { return f2(x - y, y); }
int main() {
int n, k;
cin >> n >> k;
combination c(n - k + 1);
for (int i = 1; i <= k; i++) {
mint red = c(n - k + 1, i);
mint blue = f(k, i);
mint ans = red * blue;
cout << ans.x << endl;
}
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 797,611 | 797,612 | u005006157 | cpp |
p02990 | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define lb lower_bound
#define ub upper_bound
#define owo \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) \
for (long blockTime = 0; \
(blockTime == 0 ? (blockTime = clock()) != 0 : false); \
debug("%s time : %.4fs\n", d, \
(double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> PII;
typedef pair<int, int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a, ll b) {
if (!b)
return a;
else
return gcd(b, a % b);
}
vector<ll> fact;
vector<ll> ifact;
ll add(ll a, ll b) {
a += b;
while (a >= MOD)
a -= MOD;
return a;
}
ll mult(ll a, ll b) { return (a * 1LL * b) % MOD; }
ll binpow(ll a, ll b) {
ll r = 1;
while (b) {
if (b & 1)
r = mult(r, a);
a = mult(a, a);
b >>= 1;
}
return r;
}
ll choose(ll a, ll b) {
if (a < b)
return 0;
if (b == 0)
return 1;
if (a == b)
return 1;
ll r = mult(ifact[b], ifact[a - b]);
r = mult(r, fact[a]);
return r;
}
ll inv(int a) { return binpow(a, MOD - 2); }
void init(ll n) {
fact.clear();
ifact.clear();
fact.resize(n + 1);
ifact.resize(n + 1);
ifact[0] = 1;
fact[0] = 1;
for (int i = 1; i <= n; i++) {
fact[i] = mult(fact[i - 1], i);
}
ifact[n] = inv(fact[n]);
for (int i = n - 1; i >= 1; i--) {
ifact[i] = mult(ifact[i + 1], i + 1);
}
}
ll rchoose(ll n, ll r) {
ll res = 1;
for (int i = 0; i < r; i++)
res = mult(res, n - i);
return res;
}
int main() {
ll n, k;
cin >> n >> k;
init(n);
ll red = n - k;
for (ll i = 1; i <= k; i++) {
cout << mult(choose(red + 1, i), choose(k - 1, i - 1)) << '\n';
}
}
| #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define lb lower_bound
#define ub upper_bound
#define owo \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) \
for (long blockTime = 0; \
(blockTime == 0 ? (blockTime = clock()) != 0 : false); \
debug("%s time : %.4fs\n", d, \
(double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> PII;
typedef pair<int, int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a, ll b) {
if (!b)
return a;
else
return gcd(b, a % b);
}
vector<ll> fact;
vector<ll> ifact;
ll add(ll a, ll b) {
a += b;
while (a >= MOD)
a -= MOD;
return a;
}
ll mult(ll a, ll b) { return (a * 1LL * b) % MOD; }
ll binpow(ll a, ll b) {
ll r = 1;
while (b) {
if (b & 1)
r = mult(r, a);
a = mult(a, a);
b >>= 1;
}
return r;
}
ll choose(ll a, ll b) {
if (a < b)
return 0;
if (b == 0)
return 1;
if (a == b)
return 1;
ll r = mult(ifact[b], ifact[a - b]);
r = mult(r, fact[a]);
return r;
}
ll inv(int a) { return binpow(a, MOD - 2); }
void init(ll n) {
fact.clear();
ifact.clear();
fact.resize(n + 1);
ifact.resize(n + 1);
ifact[0] = 1;
fact[0] = 1;
for (int i = 1; i <= n; i++) {
fact[i] = mult(fact[i - 1], i);
}
ifact[n] = inv(fact[n]);
for (int i = n - 1; i >= 1; i--) {
ifact[i] = mult(ifact[i + 1], i + 1);
}
}
ll rchoose(ll n, ll r) {
ll res = 1;
for (int i = 0; i < r; i++)
res = mult(res, n - i);
return res;
}
int main() {
ll n, k;
cin >> n >> k;
init(n);
ll red = n - k;
for (ll i = 1; i <= k; i++) {
cout << mult(choose(red + 1, i), choose(k - 1, i - 1)) << '\n';
}
}
| [
"preprocessor.define.value.change",
"literal.float.change"
] | 797,615 | 797,616 | u300665398 | cpp |
p02990 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;
int modpow(ll a, ll n, ll p) {
if (n == 0)
return 1;
if (n == 1)
return a % p;
if (n % 2 == 1)
return (a * modpow(a, n - 1, p)) % p;
ll t = modpow(a, n / 2, p);
return (t * t) % p;
}
ll modnCa(ll n, ll a, ll p) {
ll upper = 1;
ll lower = 1;
for (ll i = 1; i <= a; i++) {
upper *= n - i + 1;
upper %= p;
lower *= i;
lower %= p;
}
ll inv_lower = modpow(lower, p - 2, p);
return (upper * inv_lower) % p;
}
int main() {
ll n, k;
cin >> n >> k;
ll mod = 1000000007;
for (ll i = 1; i < k + 1; i++) {
ll ans = modnCa(n - k + 1, i, mod) * modnCa(k - 1, i - 1, mod);
cout << ans << endl;
}
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;
int modpow(ll a, ll n, ll p) {
if (n == 0)
return 1;
if (n == 1)
return a % p;
if (n % 2 == 1)
return (a * modpow(a, n - 1, p)) % p;
ll t = modpow(a, n / 2, p);
return (t * t) % p;
}
ll modnCa(ll n, ll a, ll p) {
ll upper = 1;
ll lower = 1;
for (ll i = 1; i <= a; i++) {
upper *= n - i + 1;
upper %= p;
lower *= i;
lower %= p;
}
ll inv_lower = modpow(lower, p - 2, p);
return (upper * inv_lower) % p;
}
int main() {
ll n, k;
cin >> n >> k;
ll mod = 1000000007;
for (ll i = 1; i < k + 1; i++) {
ll ans = modnCa(n - k + 1, i, mod) * modnCa(k - 1, i - 1, mod);
ans %= mod;
cout << ans << endl;
}
}
| [
"assignment.add"
] | 797,617 | 797,618 | u886613668 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define REP(i, m, n) for (ll(i) = (m), (i_len) = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)), greater<ll>())
#define pb push_back
int main() {
ll N, K;
cin >> N >> K;
mat C(2001, vec(2001, 0));
C[0][0] = 1;
REP(i, 1, 2001) {
C[i][0] = 1;
REP(j, 1, i + 1) { C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD; }
}
REP(i, 1, K + 1) PR(C[K - 1][i - 1] * C[N - K + 1][i]);
return 0;
}
/*
*/ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define REP(i, m, n) for (ll(i) = (m), (i_len) = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)), greater<ll>())
#define pb push_back
int main() {
ll N, K;
cin >> N >> K;
mat C(2001, vec(2001, 0));
C[0][0] = 1;
REP(i, 1, 2001) {
C[i][0] = 1;
REP(j, 1, i + 1) { C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD; }
}
REP(i, 1, K + 1) PR((C[K - 1][i - 1] * C[N - K + 1][i]) % MOD);
return 0;
}
/*
*/ | [
"call.arguments.change",
"call.arguments.add"
] | 797,619 | 797,620 | u768347697 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
long long moder = 1000000007;
long long fac[5005] = {1};
long long multi(long long a, long long b) {
if (b == 0)
return 0;
if (b == 1)
return a;
long long ret = multi(a, b / 2);
ret *= ret;
ret %= moder;
if (b % 2)
ret *= a;
return ret % moder;
}
long long F(long long n) {
long long &ret = fac[n];
if (~ret)
return ret;
if (n <= 1)
return ret = 1;
return ret = (n * F(n - 1)) % moder;
}
long long C(long long n, long long r) {
long long up = F(n);
long long down = F(n - r) * F(r);
down %= moder;
return (up * multi(down, moder - 2)) % moder;
}
long long H(long long n, long long r) { return C(n + r - 1, r); }
int main() {
memset(fac, -1, sizeof(fac));
long long n, k;
cin >> n >> k;
long long blue = k;
long long red = n - k;
for (long long i = 1; i <= k; i++) {
long long red_wall = i - 1;
if (red_wall > red)
cout << 0 << '\n';
else {
long long red_left = red - red_wall;
long long blue_left = blue - i;
cout << H(red_wall + 2, red_left) * H(i, blue_left) << '\n';
}
}
} | #include <bits/stdc++.h>
using namespace std;
long long moder = 1000000007;
long long fac[5005] = {1};
long long multi(long long a, long long b) {
if (b == 0)
return 0;
if (b == 1)
return a;
long long ret = multi(a, b / 2);
ret *= ret;
ret %= moder;
if (b % 2)
ret *= a;
return ret % moder;
}
long long F(long long n) {
long long &ret = fac[n];
if (~ret)
return ret;
if (n <= 1)
return ret = 1;
return ret = (n * F(n - 1)) % moder;
}
long long C(long long n, long long r) {
long long up = F(n);
long long down = F(n - r) * F(r);
down %= moder;
return (up * multi(down, moder - 2)) % moder;
}
long long H(long long n, long long r) { return C(n + r - 1, r); }
int main() {
memset(fac, -1, sizeof(fac));
long long n, k;
cin >> n >> k;
long long blue = k;
long long red = n - k;
for (long long i = 1; i <= k; i++) {
long long red_wall = i - 1;
if (red_wall > red)
cout << 0 << '\n';
else {
long long red_left = red - red_wall;
long long blue_left = blue - i;
cout << (H(red_wall + 2, red_left) * H(i, blue_left)) % moder << '\n';
}
}
} | [
"expression.operation.binary.add"
] | 797,621 | 797,622 | u371958417 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
/// Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout << #var << " " << var << endl;
#define co(q) cout << q << endl;
#define all(q) (q).begin(), (q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define MODADD(ADD_X, ADD_Y) (ADD_X + ADD_Y) % MOD;
#define MODSUB(SUB_X, SUB_Y) (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X, MUL_Y) (MUL_X * MUL_Y) % MOD;
#define LCM(LCM_X, LCM_Y) (LCM_X * LCM_Y) / __gcd(LCM_X, LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9 + 7;
const int MAX = 1e6;
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
ll fact[MAX], inverse[MAX];
ll Bigmod(int a, int b) {
if (b == 0)
return 1 % MOD;
ll x = Bigmod(a, b / 2);
x = (x * x) % MOD;
if (b % 2 == 1)
x = (x * a) % MOD;
return x;
}
ll nCr(int x, int y) {
if (x < 0 || y < 0 || x < y)
return 0;
return (fact[x] * (inverse[y] * inverse[x - y]) % MOD) % MOD;
}
void pre_cal() {
fact[0] = 1;
for (int i = 1; i <= MAX; i++)
fact[i] = (fact[i - 1] * 1LL * i) % MOD;
inverse[MAX] = Bigmod(fact[MAX], MOD - 2);
for (int i = MAX; i > 0; i--) {
inverse[i - 1] = (i * 1LL * inverse[i]) % MOD;
}
}
int main() {
FastRead
// freopen("output.txt", "w", stdout);
int n,
k;
cin >> n >> k;
int r = n - k;
pre_cal();
for (int i = 1; i <= k; i++) {
ll a = nCr(k - 1, i - 1);
ll b = nCr(r + 1, i);
ll ans = (a * b) % MOD;
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
/// Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout << #var << " " << var << endl;
#define co(q) cout << q << endl;
#define all(q) (q).begin(), (q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define MODADD(ADD_X, ADD_Y) (ADD_X + ADD_Y) % MOD;
#define MODSUB(SUB_X, SUB_Y) (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X, MUL_Y) (MUL_X * MUL_Y) % MOD;
#define LCM(LCM_X, LCM_Y) (LCM_X * LCM_Y) / __gcd(LCM_X, LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9 + 7;
const int MAX = 1e6;
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
ll fact[MAX], inverse[MAX];
ll Bigmod(int a, int b) {
if (b == 0)
return 1 % MOD;
ll x = Bigmod(a, b / 2);
x = (x * x) % MOD;
if (b % 2 == 1)
x = (x * a) % MOD;
return x;
}
ll nCr(int x, int y) {
if (x < 0 || y < 0 || x < y)
return 0;
return (fact[x] * (inverse[y] * inverse[x - y] % MOD) % MOD) % MOD;
}
void pre_cal() {
fact[0] = 1;
for (int i = 1; i <= 5000; i++)
fact[i] = (fact[i - 1] * 1LL * i) % MOD;
inverse[5000] = Bigmod(fact[5000], MOD - 2);
for (int i = 5000; i > 0; i--) {
inverse[i - 1] = (i * 1LL * inverse[i]) % MOD;
}
}
int main() {
FastRead
// freopen("output.txt", "w", stdout);
int n,
k;
cin >> n >> k;
int r = n - k;
pre_cal();
for (int i = 1; i <= k; i++) {
ll a = nCr(k - 1, i - 1);
ll b = nCr(r + 1, i);
ll ans = (a * b) % MOD;
cout << ans << endl;
}
return 0;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"assignment.variable.change",
"variable_access.subscript.index.change",
"assignment.value.change",
"call.arguments.change",
"variable_declaration.value.change",
"cont... | 797,625 | 797,624 | u642657797 | cpp |
p02990 | #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <math.h>
#include <vector>
#define irep(i, n) for (int i = 0; i < (int)(n); i++)
#define irep2(i, a, n) for (int i = (int)(a); i <= (int)(n); i++)
#define irrep(i, n) for (int i = (int)(n - 1); i > -1; i--)
#define irrep2(i, n, a) for (int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second
using namespace std;
using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;
const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dr[8] = {0, 0, 1, -1, 1, 1, -1, -1};
template <typename T, typename U>
inline ostream &operator<<(ostream &o, pair<T, U> &p) {
return o << "{" << p.first << "," << p.second << "}";
}
template <typename T> inline istream &operator>>(istream &is, vector<T> &vec) {
for (auto &v : vec) {
is >> v;
}
return is;
}
template <typename T> inline ostream &operator<<(ostream &os, vector<T> &vec) {
for (auto &v : vec) {
os << v << ",";
}
return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, vector<vector<T>> &mat) {
for (auto &row : mat) {
os << row << endl;
}
return os;
}
template <typename T> inline void chmin(T &a, T b) { a = min(a, b); }
template <typename T> inline void chmax(T &a, T b) { a = max(a, b); }
template <typename T> T ModPow(T s, T n) {
T res = 1;
while (n) {
if (n & 1) {
res *= s;
res %= MOD;
}
s *= s;
s %= MOD;
n >>= 1;
}
return res;
}
template <typename T> T ModInv(T n) { return ModPow(n, MOD - 2); }
template <typename T> T ModnCr(T n, T r) {
T x = 1, y = 1;
irep(i, r) {
x *= n - i;
x %= MOD;
y *= r - i;
y %= MOD;
}
T rtn = (x * ModInv(y)) % MOD;
return rtn;
}
int main(void) {
ll n, k;
cin >> n >> k;
cout << n - k + 1 << endl;
irep2(i, 2, k) {
ll a = ModnCr((ll)n - k + 1, (ll)i);
ll b = ModnCr((ll)k - 1, (ll)i - 1);
cout << a * b << endl;
}
return 0;
} /*atcoder*/
| #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <math.h>
#include <vector>
#define irep(i, n) for (int i = 0; i < (int)(n); i++)
#define irep2(i, a, n) for (int i = (int)(a); i <= (int)(n); i++)
#define irrep(i, n) for (int i = (int)(n - 1); i > -1; i--)
#define irrep2(i, n, a) for (int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second
using namespace std;
using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;
const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dr[8] = {0, 0, 1, -1, 1, 1, -1, -1};
template <typename T, typename U>
inline ostream &operator<<(ostream &o, pair<T, U> &p) {
return o << "{" << p.first << "," << p.second << "}";
}
template <typename T> inline istream &operator>>(istream &is, vector<T> &vec) {
for (auto &v : vec) {
is >> v;
}
return is;
}
template <typename T> inline ostream &operator<<(ostream &os, vector<T> &vec) {
for (auto &v : vec) {
os << v << ",";
}
return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, vector<vector<T>> &mat) {
for (auto &row : mat) {
os << row << endl;
}
return os;
}
template <typename T> inline void chmin(T &a, T b) { a = min(a, b); }
template <typename T> inline void chmax(T &a, T b) { a = max(a, b); }
template <typename T> T ModPow(T s, T n) {
T res = 1;
while (n) {
if (n & 1) {
res *= s;
res %= MOD;
}
s *= s;
s %= MOD;
n >>= 1;
}
return res;
}
template <typename T> T ModInv(T n) { return ModPow(n, MOD - 2); }
template <typename T> T ModnCr(T n, T r) {
T x = 1, y = 1;
irep(i, r) {
x *= n - i;
x %= MOD;
y *= r - i;
y %= MOD;
}
T rtn = (x * ModInv(y)) % MOD;
return rtn;
}
int main(void) {
ll n, k;
cin >> n >> k;
cout << n - k + 1 << endl;
irep2(i, 2, k) {
ll a = ModnCr((ll)n - k + 1, (ll)i);
ll b = ModnCr((ll)k - 1, (ll)i - 1);
cout << (a * b) % MOD << endl;
}
return 0;
} /*atcoder*/
| [
"expression.operation.binary.add"
] | 797,626 | 797,627 | u829260400 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
//(a+b-1)/b
// priority_queue<ll, vector<ll>, greater<ll>> q;
template <int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<MOD>;
mint Combination(ll n, ll k) {
k = min(k, n - k);
mint ret = 1;
mint div = 1;
for (int i = 0; i < k; i++) {
ret *= (n - i);
div *= (k - i);
}
ret /= div;
return ret;
}
signed main() {
// cout << fixed << setprecision(10);
ll n, b;
cin >> n >> b;
ll r = n - b;
for (int i = 1; i <= b; i++) {
if (i > r + i) {
cout << 0 << endl;
continue;
}
mint ans = Combination(r + 1, i);
ans *= Combination(b - 1, i - 1);
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
//(a+b-1)/b
// priority_queue<ll, vector<ll>, greater<ll>> q;
template <int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<MOD>;
mint Combination(ll n, ll k) {
k = min(k, n - k);
mint ret = 1;
mint div = 1;
for (int i = 0; i < k; i++) {
ret *= (n - i);
div *= (k - i);
}
ret /= div;
return ret;
}
signed main() {
// cout << fixed << setprecision(10);
ll n, b;
cin >> n >> b;
ll r = n - b;
for (int i = 1; i <= b; i++) {
if (i > r + 1) {
cout << 0 << endl;
continue;
}
mint ans = Combination(r + 1, i);
ans *= Combination(b - 1, i - 1);
cout << ans << endl;
}
return 0;
} | [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.branch.if.condition.change"
] | 797,631 | 797,632 | u164181205 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
for (ll i = 1; i <= K; i++) {
cout << COM(N - K + 1, i) * COM(K - 1, i - 1) % 1000000007 << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll N, K;
cin >> N >> K;
COMinit();
for (ll i = 1; i <= K; i++) {
cout << COM(N - K + 1, i) * COM(K - 1, i - 1) % 1000000007 << endl;
}
return 0;
} | [
"call.add"
] | 797,633 | 797,634 | u109191542 | cpp |
p02990 | #include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define pb push_back
#define int long long
#define swap(x, y) (x ^= y ^= x ^= y)
#define debug1(a) cerr << #a << " = " << (a) << endl;
#define debug2(a, b) \
cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define debug3(a, b, c) \
cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << endl;
#define debug4(a, b, c, d) \
cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << ", " << #d << " = " << (d) << endl;
using namespace std;
#define mod 1000000007
long long modexpo(long long x, long long p) {
int res = 1;
x = x % mod;
while (p) {
if (p % 2)
res = res * x;
p >>= 1;
x = x * x % mod;
res %= mod;
}
return res;
}
// int max(int a,int b){return (a>b?a:b);}
// int min(int a,int b){return (a<b?a:b);}
struct compare {
bool operator()(const pair<int, int> a, const pair<int, int> b) const {
return a.first < b.first;
}
};
const int nax = 2e3 + 5;
int fib[nax], inv[nax];
int nCk(int n, int k) {
if (k > n) {
return 1;
}
int temp = fib[n];
temp *= inv[k];
temp %= mod;
temp *= inv[n - k];
temp %= mod;
return temp;
}
int32_t main() {
IOS fib[0] = inv[0] = 1;
fib[1] = inv[1] = 1;
for (int i = 2; i < nax; i++) {
fib[i] = fib[i - 1] * i;
fib[i] %= mod;
inv[i] = modexpo(fib[i], mod - 2);
}
int n, k;
cin >> n >> k;
int slots = n - k + 1;
for (int i = 1; i <= k; i++) {
int x = nCk(k - 1, i - 1);
// cout << x << endl;
int y = nCk(slots, i);
x *= y;
x %= mod;
cout << x << endl;
}
} | #include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define pb push_back
#define int long long
#define swap(x, y) (x ^= y ^= x ^= y)
#define debug1(a) cerr << #a << " = " << (a) << endl;
#define debug2(a, b) \
cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << endl;
#define debug3(a, b, c) \
cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << endl;
#define debug4(a, b, c, d) \
cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c \
<< " = " << (c) << ", " << #d << " = " << (d) << endl;
using namespace std;
#define mod 1000000007
long long modexpo(long long x, long long p) {
int res = 1;
x = x % mod;
while (p) {
if (p % 2)
res = res * x;
p >>= 1;
x = x * x % mod;
res %= mod;
}
return res;
}
// int max(int a,int b){return (a>b?a:b);}
// int min(int a,int b){return (a<b?a:b);}
struct compare {
bool operator()(const pair<int, int> a, const pair<int, int> b) const {
return a.first < b.first;
}
};
const int nax = 2e3 + 5;
int fib[nax], inv[nax];
int nCk(int n, int k) {
if (k > n) {
return 0;
}
int temp = fib[n];
temp *= inv[k];
temp %= mod;
temp *= inv[n - k];
temp %= mod;
return temp;
}
int32_t main() {
IOS fib[0] = inv[0] = 1;
fib[1] = inv[1] = 1;
for (int i = 2; i < nax; i++) {
fib[i] = fib[i - 1] * i;
fib[i] %= mod;
inv[i] = modexpo(fib[i], mod - 2);
}
int n, k;
cin >> n >> k;
int slots = n - k + 1;
// debug3(p,q, slots);
for (int i = 1; i <= k; i++) {
int x = nCk(k - 1, i - 1);
// cout << x << endl;
int y = nCk(slots, i);
x *= y;
x %= mod;
cout << x << endl;
}
} | [
"literal.number.change",
"function.return_value.change"
] | 797,637 | 797,638 | u432498296 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep_r(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define resize(x, n) x.resize(n)
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX = 100000;
struct edge {
ll from, to, weight;
edge(ll f, ll t, ll w) : from(f), to(t), weight(w) {}
};
vector<vector<edge>> edges;
vector<vector<ll>> graph;
vector<bool> visited;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, k;
ll dp[2001][2001];
ll c(ll n, ll r) {
if (n < r)
return 0;
if (dp[n][r] != -1)
return dp[n][r];
if (n == r || r == 0)
return 1;
if (r == 1)
return dp[n][r] = n;
return dp[n][r] = (c(n - 1, r - 1) + c(n - 1, r)) % mod;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
memset(dp, -1, sizeof(dp));
cin >> n;
cin >> k;
ll blue = k, red = n - k;
for (ll i = 1; i <= k; i++) {
ll answer = c(red + 1, i) * c(blue - 1, i - 1);
// printf("%lld回の場合 %lld\n", i, answer);
cout << answer << "\n";
}
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep_r(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define resize(x, n) x.resize(n)
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX = 100000;
struct edge {
ll from, to, weight;
edge(ll f, ll t, ll w) : from(f), to(t), weight(w) {}
};
vector<vector<edge>> edges;
vector<vector<ll>> graph;
vector<bool> visited;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, k;
ll dp[2001][2001];
ll c(ll n, ll r) {
if (n < r)
return 0;
if (dp[n][r] != -1)
return dp[n][r];
if (n == r || r == 0)
return 1;
if (r == 1)
return dp[n][r] = n;
return dp[n][r] = (c(n - 1, r - 1) + c(n - 1, r)) % mod;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
memset(dp, -1, sizeof(dp));
cin >> n;
cin >> k;
ll blue = k, red = n - k;
for (ll i = 1; i <= k; i++) {
ll answer = c(red + 1, i) * c(blue - 1, i - 1) % mod;
// printf("%lld回の場合 %lld\n", i, answer);
cout << answer << "\n";
}
} | [
"assignment.change"
] | 797,643 | 797,644 | u915582296 | cpp |
p02990 |
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} comb(10005);
// nPk
mint f(int n, int k) {
if (n < 0)
return 0;
// nPk = nCk * k!
mint res = comb(n, k);
res *= comb.fact[k];
return res;
}
//組み合わせの数nCrを計算
int calcNumOfCombination(int n, int r) {
int num = 1;
for (int i = 1; i <= r; i++) {
num = num * (n - i + 1) / i;
}
return num;
}
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; i++) {
mint t1 = comb(k - 1, i - 1);
mint t2 = comb(n - k + 1, i - 1);
t1 *= t2;
cout << t1 << endl;
}
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} comb(10005);
// nPk
mint f(int n, int k) {
if (n < 0)
return 0;
// nPk = nCk * k!
mint res = comb(n, k);
res *= comb.fact[k];
return res;
}
//組み合わせの数nCrを計算
int calcNumOfCombination(int n, int r) {
int num = 1;
for (int i = 1; i <= r; i++) {
num = num * (n - i + 1) / i;
}
return num;
}
int main() {
ll n, k;
cin >> n >> k;
for (ll i = 1; i <= k; i++) {
mint t1 = comb(k - 1, i - 1);
mint t2 = comb(n - k + 1, i);
t1 *= t2;
cout << t1 << endl;
}
}
| [
"expression.operation.binary.remove"
] | 797,647 | 797,648 | u289381123 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int vector_finder(std::vector<ll> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
struct edge {
ll to, cost;
};
const int MAX = 510000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// a^n mod を計算する
// 繰り返し二乗法を使っているので高速! O(logk)
long long modpow(long long a, long long n, long long mod) {
if (n == 0) {
return 1;
} else if (n % 2 == 1) {
return modpow(a, n - 1, mod) * a % mod;
} else {
ll t = modpow(a, n / 2, mod);
return t * t % mod;
}
}
int main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 0; i < K; ++i) {
ll ans = 0;
ans = COM(N - K + 1, i + 1) % MOD;
ll a = COM(K - 1, i) % MOD;
ans *= a % MOD;
cout << ans << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int vector_finder(std::vector<ll> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
struct edge {
ll to, cost;
};
const int MAX = 510000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// a^n mod を計算する
// 繰り返し二乗法を使っているので高速! O(logk)
long long modpow(long long a, long long n, long long mod) {
if (n == 0) {
return 1;
} else if (n % 2 == 1) {
return modpow(a, n - 1, mod) * a % mod;
} else {
ll t = modpow(a, n / 2, mod);
return t * t % mod;
}
}
int main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 0; i < K; ++i) {
ll ans = 0;
ans = COM(N - K + 1, i + 1) % MOD;
ll a = COM(K - 1, i) % MOD;
ans *= a % MOD;
ans %= MOD;
cout << ans << endl;
}
} | [
"assignment.add"
] | 797,653 | 797,654 | u308463793 | cpp |
p02990 | #include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int INF = 1e16 + 7;
int mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int fac[2500], finv[2500], inv[2500];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < 2500; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
int COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
signed main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 1; i <= K; i++) {
int ans = COM(N - K + 1, i);
ans *= COM(K - 1, i - 1);
cout << ans << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int INF = 1e16 + 7;
int mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int fac[2500], finv[2500], inv[2500];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < 2500; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
int COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
signed main() {
int N, K;
cin >> N >> K;
COMinit();
for (int i = 1; i <= K; i++) {
int ans = COM(N - K + 1, i);
ans *= COM(K - 1, i - 1);
cout << ans % mod << endl;
}
}
| [
"expression.operation.binary.add"
] | 797,666 | 797,667 | u237390401 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.