9175 | 2024-02-16 20:36:52 | 111 | Séta Alatti Terület | cpp17 | Wrong answer 0/100 | 231ms | 67568 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
int pow_mod(int x, int p) {
int r = 1;
while (p > 0) {
if (p % 2 == 1) {
r *= x;
r %= MOD;
}
p /= 2;
x *= x;
x %= MOD;
}
return r;
}
int inv_mod(int x) {
return pow_mod(x, MOD - 2);
}
int fac_mod(int x) {
static vector<int> v = { 1 };
while (v.size() - 1 < x) {
v.push_back(v.back() * v.size() % MOD);
}
return v[x];
}
int inv_fac_mod(int x) {
static vector<int> v = { 1 };
while (v.size() - 1 < x) {
v.push_back(v.back() * inv_mod(v.size()) % MOD);
}
return v[x];
}
int bin_mod(int n, int k) {
if (k < 0 || k > n) {
return 0;
}
return fac_mod(n) * inv_fac_mod(n - k) % MOD * inv_fac_mod(k) % MOD;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
#ifdef CB
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
int N, M, P, R;
cin >> N >> M >> P >> R;
int r = N / P, c = M / P;
int ans = bin_mod(N + M, N) - bin_mod(r + c, r) + MOD;
ans %= MOD;
ans *= inv_mod(P);
ans %= MOD;
cout << ans << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2016 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 3ms | 2232 KiB | ||||
4 | Wrong answer | 3ms | 2464 KiB | ||||
5 | Wrong answer | 3ms | 2652 KiB | ||||
6 | Wrong answer | 2ms | 2740 KiB | ||||
7 | Wrong answer | 3ms | 2864 KiB | ||||
8 | Wrong answer | 2ms | 2956 KiB | ||||
9 | Accepted | 2ms | 3060 KiB | ||||
10 | Wrong answer | 2ms | 2948 KiB | ||||
11 | Wrong answer | 2ms | 2948 KiB | ||||
12 | Wrong answer | 3ms | 3080 KiB | ||||
13 | Wrong answer | 2ms | 3168 KiB | ||||
subtask3 | 0/21 | ||||||
14 | Wrong answer | 2ms | 3164 KiB | ||||
15 | Wrong answer | 2ms | 3264 KiB | ||||
16 | Wrong answer | 3ms | 3392 KiB | ||||
17 | Wrong answer | 3ms | 3272 KiB | ||||
18 | Wrong answer | 2ms | 3280 KiB | ||||
19 | Wrong answer | 3ms | 3404 KiB | ||||
20 | Wrong answer | 3ms | 3280 KiB | ||||
21 | Wrong answer | 2ms | 3272 KiB | ||||
22 | Wrong answer | 2ms | 3276 KiB | ||||
subtask4 | 0/25 | ||||||
23 | Accepted | 24ms | 9820 KiB | ||||
24 | Wrong answer | 209ms | 52320 KiB | ||||
25 | Accepted | 209ms | 52324 KiB | ||||
26 | Wrong answer | 24ms | 9820 KiB | ||||
27 | Wrong answer | 209ms | 52312 KiB | ||||
28 | Wrong answer | 221ms | 52440 KiB | ||||
subtask5 | 0/38 | ||||||
29 | Wrong answer | 209ms | 43704 KiB | ||||
30 | Wrong answer | 203ms | 43692 KiB | ||||
31 | Wrong answer | 231ms | 66812 KiB | ||||
32 | Wrong answer | 231ms | 66952 KiB | ||||
33 | Wrong answer | 222ms | 67044 KiB | ||||
34 | Wrong answer | 223ms | 67112 KiB | ||||
35 | Wrong answer | 221ms | 67116 KiB | ||||
36 | Wrong answer | 231ms | 67320 KiB | ||||
37 | Wrong answer | 224ms | 67568 KiB |