# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20205 | veckal | Ω (kriii4_P3) | C++14 | 491 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
const int MOD = 1000000007;
typedef long long ll;
ll pow(ll base, int exp) {
if (exp == 1) return base;
ll ret = pow(base, exp>>1);
ret = ret * ret % MOD;
if (exp&1) ret = ret * base % MOD;
return ret;
}
ll inv(ll base) {
return pow(base, MOD-2);
}
int p, q, n, k;
int main() {
scanf("%d%d%d%d", &p, &q, &n, &k);
p = q * inv(p) % MOD;
int m = p * inv((1+MOD-p)%MOD);
int ans = inv((1-pow(m, n)+MOD)%MOD) * ((1-pow(m, k)+MOD)%MOD) % MOD;
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |