# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
20097 |
2016-02-25T12:16:17 Z |
kk1401 |
괄호 (kriii4_R) |
C++ |
|
4 ms |
24520 KB |
#include<stdio.h>
#define M 1000000007ll
int n;
long long d[1000001],k,pow[1000001],comb[1000001];
int main()
{
int i;
scanf("%d%lld",&n,&k);
d[1] = k;
pow[0]=1ll;
for(i=1; i<=n; i++) pow[i] = (pow[i-1] * k) % M;
comb[1] = 2;
for(i=2; i<=n; i++) comb[i] = ((comb[i-1] / (long long)i) * (4ll*(long long)i - 2ll)) % M;
for(i=2; i<=n; i++){
if(i%2 == 0) d[i] = (d[i-1] * (k + 1ll)) % M;
else d[i] = (d[i-1] * (k + 1ll) - (pow[(i-1)/2] * comb[(i-1)/2] / (((long long)i-1ll)/2ll+1ll)) % M + M) % M;
}
printf("%lld\n",d[n]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
24520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |