# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
20091 |
2016-02-25T11:13:36 Z |
jihoon |
괄호 (kriii4_R) |
C++ |
|
702 ms |
24520 KB |
#include<cstdio>
#define je 1000000007
long long fact[2000001];
long long seq[1000001];
long long gop(long long x,long long y){
x%=je;y%=je;
x*=y;x%=je;
return x;
}
long long hap(long long x,long long y){
x%=je;y%=je;
x+=y;x%=je;
return x;
}
long long div(long long x,long long y){
x%=je;y%=je;
int left=je-2;
long long gopp=y,ret=1;
while(left){
if(left&1){
ret=gop(ret,gopp);
}
gopp=gop(gopp,gopp);
left >>= 1;
}
ret=gop(ret,x);
return ret;
}
int main(){
int n,k;
long long su;
scanf("%d %d",&n,&k);
seq[0]=1;
fact[0]=1;
su=div(1,k);
for(int i=1;i<=n;i++){
fact[i]=gop(fact[i-1],i);
}
for(int i=1;i<=n;i++){
seq[i]=gop(seq[i-1],k+1);
if(i%2){
su=gop(su,k);
seq[i]=hap(seq[i],je-gop(su,div(div(div(fact[i-1],fact[i/2]),fact[i/2]),(i/2)+1)));
}
}
printf("%lld\n",seq[n]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
214 ms |
24520 KB |
Output is correct |
2 |
Correct |
40 ms |
24520 KB |
Output is correct |
3 |
Correct |
519 ms |
24520 KB |
Output is correct |
4 |
Correct |
579 ms |
24520 KB |
Output is correct |
5 |
Correct |
590 ms |
24520 KB |
Output is correct |
6 |
Correct |
324 ms |
24520 KB |
Output is correct |
7 |
Correct |
368 ms |
24520 KB |
Output is correct |
8 |
Correct |
246 ms |
24520 KB |
Output is correct |
9 |
Correct |
102 ms |
24520 KB |
Output is correct |
10 |
Correct |
25 ms |
24520 KB |
Output is correct |
11 |
Correct |
27 ms |
24520 KB |
Output is correct |
12 |
Correct |
528 ms |
24520 KB |
Output is correct |
13 |
Correct |
498 ms |
24520 KB |
Output is correct |
14 |
Correct |
214 ms |
24520 KB |
Output is correct |
15 |
Correct |
234 ms |
24520 KB |
Output is correct |
16 |
Correct |
212 ms |
24520 KB |
Output is correct |
17 |
Correct |
637 ms |
24520 KB |
Output is correct |
18 |
Correct |
658 ms |
24520 KB |
Output is correct |
19 |
Correct |
701 ms |
24520 KB |
Output is correct |
20 |
Correct |
701 ms |
24520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
24520 KB |
Output is correct |
2 |
Correct |
62 ms |
24520 KB |
Output is correct |
3 |
Correct |
127 ms |
24520 KB |
Output is correct |
4 |
Correct |
635 ms |
24520 KB |
Output is correct |
5 |
Correct |
398 ms |
24520 KB |
Output is correct |
6 |
Correct |
487 ms |
24520 KB |
Output is correct |
7 |
Correct |
341 ms |
24520 KB |
Output is correct |
8 |
Correct |
193 ms |
24520 KB |
Output is correct |
9 |
Correct |
335 ms |
24520 KB |
Output is correct |
10 |
Correct |
41 ms |
24520 KB |
Output is correct |
11 |
Correct |
549 ms |
24520 KB |
Output is correct |
12 |
Correct |
574 ms |
24520 KB |
Output is correct |
13 |
Correct |
548 ms |
24520 KB |
Output is correct |
14 |
Correct |
259 ms |
24520 KB |
Output is correct |
15 |
Correct |
320 ms |
24520 KB |
Output is correct |
16 |
Correct |
319 ms |
24520 KB |
Output is correct |
17 |
Correct |
54 ms |
24520 KB |
Output is correct |
18 |
Correct |
690 ms |
24520 KB |
Output is correct |
19 |
Correct |
702 ms |
24520 KB |
Output is correct |
20 |
Correct |
698 ms |
24520 KB |
Output is correct |