# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19993 |
2016-02-25T08:13:48 Z |
xdoju |
괄호 (kriii4_R) |
C++14 |
|
604 ms |
1084 KB |
#include <stdio.h>
const int MOD = 1000000007;
int mul(int x, int y){ return (long long)x * y % MOD; }
int power(int x, int y){
if(y == 0) return 1;
int r = power(x, y / 2);
r = mul(r, r);
if(y % 2 == 1) r = mul(r, x);
return r;
}
int modinv(int x){ return power(x, MOD - 2); }
int main(){
int N, K; scanf("%d%d", &N, &K);
int ans = 0, v = power(K, N);
for(int op = N; op >= 0; op--){
int cl = N - op;
if(cl > op) break;
ans += v; ans %= MOD;
v = mul(v, modinv(K));
v = mul(v, N - cl * 2 - 1);
v = mul(v, modinv(cl + 1));
if(cl != 0){
v = mul(v, N - cl + 1);
v = mul(v, modinv(N - 2 * cl + 1));
}
}
printf("%d\n", ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
1084 KB |
Output is correct |
2 |
Correct |
37 ms |
1084 KB |
Output is correct |
3 |
Correct |
445 ms |
1084 KB |
Output is correct |
4 |
Correct |
496 ms |
1084 KB |
Output is correct |
5 |
Correct |
506 ms |
1084 KB |
Output is correct |
6 |
Correct |
281 ms |
1084 KB |
Output is correct |
7 |
Correct |
315 ms |
1084 KB |
Output is correct |
8 |
Correct |
212 ms |
1084 KB |
Output is correct |
9 |
Correct |
87 ms |
1084 KB |
Output is correct |
10 |
Correct |
21 ms |
1084 KB |
Output is correct |
11 |
Correct |
23 ms |
1084 KB |
Output is correct |
12 |
Correct |
455 ms |
1084 KB |
Output is correct |
13 |
Correct |
429 ms |
1084 KB |
Output is correct |
14 |
Correct |
187 ms |
1084 KB |
Output is correct |
15 |
Correct |
201 ms |
1084 KB |
Output is correct |
16 |
Correct |
182 ms |
1084 KB |
Output is correct |
17 |
Correct |
554 ms |
1084 KB |
Output is correct |
18 |
Correct |
567 ms |
1084 KB |
Output is correct |
19 |
Correct |
604 ms |
1084 KB |
Output is correct |
20 |
Correct |
604 ms |
1084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
1084 KB |
Output is correct |
2 |
Correct |
53 ms |
1084 KB |
Output is correct |
3 |
Correct |
108 ms |
1084 KB |
Output is correct |
4 |
Correct |
545 ms |
1084 KB |
Output is correct |
5 |
Correct |
342 ms |
1084 KB |
Output is correct |
6 |
Correct |
422 ms |
1084 KB |
Output is correct |
7 |
Correct |
292 ms |
1084 KB |
Output is correct |
8 |
Correct |
166 ms |
1084 KB |
Output is correct |
9 |
Correct |
288 ms |
1084 KB |
Output is correct |
10 |
Correct |
38 ms |
1084 KB |
Output is correct |
11 |
Correct |
475 ms |
1084 KB |
Output is correct |
12 |
Correct |
497 ms |
1084 KB |
Output is correct |
13 |
Correct |
471 ms |
1084 KB |
Output is correct |
14 |
Correct |
223 ms |
1084 KB |
Output is correct |
15 |
Correct |
275 ms |
1084 KB |
Output is correct |
16 |
Correct |
277 ms |
1084 KB |
Output is correct |
17 |
Correct |
46 ms |
1084 KB |
Output is correct |
18 |
Correct |
604 ms |
1084 KB |
Output is correct |
19 |
Correct |
603 ms |
1084 KB |
Output is correct |
20 |
Correct |
603 ms |
1084 KB |
Output is correct |