9174 | 2024-02-16 20:35:32 | 111 | Séta Alatti Terület | cpp17 | Wrong answer 0/100 | 222ms | 67020 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);
ans *= inv_mod(P);
ans %= MOD;
cout << ans << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1960 KiB | ||||
2 | Accepted | 3ms | 2084 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 3ms | 2296 KiB | ||||
4 | Wrong answer | 3ms | 2532 KiB | ||||
5 | Wrong answer | 3ms | 2672 KiB | ||||
6 | Wrong answer | 3ms | 2644 KiB | ||||
7 | Wrong answer | 3ms | 2908 KiB | ||||
8 | Wrong answer | 3ms | 2856 KiB | ||||
9 | Accepted | 2ms | 2740 KiB | ||||
10 | Wrong answer | 3ms | 2876 KiB | ||||
11 | Wrong answer | 3ms | 2952 KiB | ||||
12 | Wrong answer | 3ms | 3092 KiB | ||||
13 | Wrong answer | 3ms | 3096 KiB | ||||
subtask3 | 0/21 | ||||||
14 | Wrong answer | 3ms | 3208 KiB | ||||
15 | Wrong answer | 2ms | 3116 KiB | ||||
16 | Wrong answer | 3ms | 3124 KiB | ||||
17 | Wrong answer | 3ms | 3136 KiB | ||||
18 | Wrong answer | 3ms | 3140 KiB | ||||
19 | Wrong answer | 3ms | 3424 KiB | ||||
20 | Wrong answer | 3ms | 3408 KiB | ||||
21 | Wrong answer | 3ms | 3420 KiB | ||||
22 | Wrong answer | 3ms | 3420 KiB | ||||
subtask4 | 0/25 | ||||||
23 | Accepted | 24ms | 9968 KiB | ||||
24 | Wrong answer | 209ms | 52472 KiB | ||||
25 | Accepted | 209ms | 52724 KiB | ||||
26 | Wrong answer | 25ms | 10312 KiB | ||||
27 | Wrong answer | 209ms | 52856 KiB | ||||
28 | Wrong answer | 209ms | 52656 KiB | ||||
subtask5 | 0/38 | ||||||
29 | Wrong answer | 202ms | 43840 KiB | ||||
30 | Wrong answer | 202ms | 43844 KiB | ||||
31 | Wrong answer | 221ms | 66836 KiB | ||||
32 | Wrong answer | 221ms | 66844 KiB | ||||
33 | Wrong answer | 221ms | 66844 KiB | ||||
34 | Wrong answer | 221ms | 66916 KiB | ||||
35 | Wrong answer | 221ms | 67020 KiB | ||||
36 | Wrong answer | 221ms | 66892 KiB | ||||
37 | Wrong answer | 222ms | 66896 KiB |