# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19009 |
2016-02-17T02:57:59 Z |
kriii |
괄호 (kriii4_R) |
C++14 |
|
38 ms |
8896 KB |
#include <stdio.h>
const long long mod = 1000000007;
long long inv[500002],cat[500001];
int main()
{
int n,k; scanf ("%d %d",&n,&k);
inv[1] = 1;
for (int i=2;i<=n/2+1;i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
cat[0] = 1;
for (int i=1;i<=n/2;i++) cat[i] = (4 * i - 2) * inv[i+1] % mod * cat[i-1] % mod;
long long u = 1;
for (int i=1;i<=n/2;i++){
u = u * k % mod;
cat[i] = cat[i] * u % mod;
}
long long ans = 1;
for (int i=0;i<n;i++){
ans = ans * (k + 1) % mod;
if (i % 2 == 0) ans = (ans + mod - cat[i/2]) % mod;
}
printf ("%lld\n",ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
8896 KB |
Output is correct |
2 |
Correct |
3 ms |
8896 KB |
Output is correct |
3 |
Correct |
28 ms |
8896 KB |
Output is correct |
4 |
Correct |
31 ms |
8896 KB |
Output is correct |
5 |
Correct |
32 ms |
8896 KB |
Output is correct |
6 |
Correct |
18 ms |
8896 KB |
Output is correct |
7 |
Correct |
20 ms |
8896 KB |
Output is correct |
8 |
Correct |
14 ms |
8896 KB |
Output is correct |
9 |
Correct |
6 ms |
8896 KB |
Output is correct |
10 |
Correct |
0 ms |
8896 KB |
Output is correct |
11 |
Correct |
0 ms |
8896 KB |
Output is correct |
12 |
Correct |
26 ms |
8896 KB |
Output is correct |
13 |
Correct |
27 ms |
8896 KB |
Output is correct |
14 |
Correct |
12 ms |
8896 KB |
Output is correct |
15 |
Correct |
13 ms |
8896 KB |
Output is correct |
16 |
Correct |
8 ms |
8896 KB |
Output is correct |
17 |
Correct |
35 ms |
8896 KB |
Output is correct |
18 |
Correct |
35 ms |
8896 KB |
Output is correct |
19 |
Correct |
33 ms |
8896 KB |
Output is correct |
20 |
Correct |
38 ms |
8896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8896 KB |
Output is correct |
2 |
Correct |
0 ms |
8896 KB |
Output is correct |
3 |
Correct |
3 ms |
8896 KB |
Output is correct |
4 |
Correct |
30 ms |
8896 KB |
Output is correct |
5 |
Correct |
17 ms |
8896 KB |
Output is correct |
6 |
Correct |
26 ms |
8896 KB |
Output is correct |
7 |
Correct |
15 ms |
8896 KB |
Output is correct |
8 |
Correct |
11 ms |
8896 KB |
Output is correct |
9 |
Correct |
18 ms |
8896 KB |
Output is correct |
10 |
Correct |
0 ms |
8896 KB |
Output is correct |
11 |
Correct |
29 ms |
8896 KB |
Output is correct |
12 |
Correct |
27 ms |
8896 KB |
Output is correct |
13 |
Correct |
29 ms |
8896 KB |
Output is correct |
14 |
Correct |
14 ms |
8896 KB |
Output is correct |
15 |
Correct |
18 ms |
8896 KB |
Output is correct |
16 |
Correct |
18 ms |
8896 KB |
Output is correct |
17 |
Correct |
0 ms |
8896 KB |
Output is correct |
18 |
Correct |
38 ms |
8896 KB |
Output is correct |
19 |
Correct |
34 ms |
8896 KB |
Output is correct |
20 |
Correct |
35 ms |
8896 KB |
Output is correct |