Submission #20205

# Submission time Handle Problem Language Result Execution time Memory
20205 2016-03-29T15:52:23 Z veckal Ω (kriii4_P3) C++14
0 / 100
491 ms 512 KB
#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

P3.cpp: In function 'int main()':
P3.cpp:20:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &p, &q, &n, &k);
                                      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 0 KB Output is correct
2 Runtime error 491 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 452 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Runtime error 426 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 435 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Correct 1 ms 512 KB Output is correct
9 Runtime error 428 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Correct 1 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Incorrect 1 ms 512 KB Output isn't correct
13 Incorrect 1 ms 512 KB Output isn't correct
14 Incorrect 1 ms 512 KB Output isn't correct
15 Incorrect 1 ms 512 KB Output isn't correct
16 Incorrect 2 ms 512 KB Output isn't correct
17 Incorrect 1 ms 512 KB Output isn't correct
18 Incorrect 1 ms 512 KB Output isn't correct
19 Incorrect 1 ms 512 KB Output isn't correct
20 Incorrect 1 ms 512 KB Output isn't correct
21 Incorrect 1 ms 512 KB Output isn't correct
22 Incorrect 1 ms 512 KB Output isn't correct
23 Incorrect 1 ms 512 KB Output isn't correct
24 Incorrect 1 ms 512 KB Output isn't correct
25 Incorrect 1 ms 512 KB Output isn't correct
26 Incorrect 1 ms 512 KB Output isn't correct
27 Incorrect 1 ms 512 KB Output isn't correct
28 Incorrect 1 ms 512 KB Output isn't correct
29 Incorrect 1 ms 512 KB Output isn't correct
30 Incorrect 2 ms 512 KB Output isn't correct