#include<cstdio>
long long mans,c,mul[1000003],fac[1000003],a,b,i,j,s=1,ans,X=1e9+7;
long long pow(long long aa,long long bb){
if(bb==0) return 1;
long long ret=pow(aa,bb/2);
ret=(ret*ret)%X;
if(bb&1) ret=(ret*aa)%X;
return ret;
}
long long com(long long aa,long long bb)
{
return fac[aa]*pow(fac[bb],X-2)%X*pow(fac[aa-bb],X-2)%X;
}
main()
{
scanf("%lld%lld",&a,&b);
if(b>=a)
{
printf("0");return 0;
}
fac[0]=1;
for(i=1;i<=a+1;i++)fac[i]=fac[i-1]*i%X;
for(i=b+1;i<=a;i++)
{
mans+=fac[i]*fac[a-i+1]%X*com(a+1,i+1)%X;
mans%=X;
}
printf("%lld",mans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
16708 KB |
Output is correct |
2 |
Correct |
0 ms |
16708 KB |
Output is correct |
3 |
Correct |
0 ms |
16708 KB |
Output is correct |
4 |
Correct |
0 ms |
16708 KB |
Output is correct |
5 |
Correct |
0 ms |
16708 KB |
Output is correct |
6 |
Correct |
0 ms |
16708 KB |
Output is correct |
7 |
Correct |
0 ms |
16708 KB |
Output is correct |
8 |
Correct |
0 ms |
16708 KB |
Output is correct |
9 |
Correct |
0 ms |
16708 KB |
Output is correct |
10 |
Correct |
0 ms |
16708 KB |
Output is correct |
11 |
Correct |
0 ms |
16708 KB |
Output is correct |
12 |
Correct |
0 ms |
16708 KB |
Output is correct |
13 |
Correct |
0 ms |
16708 KB |
Output is correct |
14 |
Correct |
0 ms |
16708 KB |
Output is correct |
15 |
Correct |
0 ms |
16708 KB |
Output is correct |
16 |
Correct |
0 ms |
16708 KB |
Output is correct |
17 |
Correct |
1 ms |
16708 KB |
Output is correct |
18 |
Correct |
0 ms |
16708 KB |
Output is correct |
19 |
Correct |
0 ms |
16708 KB |
Output is correct |
20 |
Correct |
0 ms |
16708 KB |
Output is correct |
21 |
Correct |
0 ms |
16708 KB |
Output is correct |
22 |
Correct |
0 ms |
16708 KB |
Output is correct |
23 |
Correct |
0 ms |
16708 KB |
Output is correct |
24 |
Correct |
2 ms |
16708 KB |
Output is correct |
25 |
Correct |
0 ms |
16708 KB |
Output is correct |
26 |
Correct |
0 ms |
16708 KB |
Output is correct |
27 |
Correct |
0 ms |
16708 KB |
Output is correct |
28 |
Correct |
0 ms |
16708 KB |
Output is correct |
29 |
Correct |
0 ms |
16708 KB |
Output is correct |
30 |
Correct |
0 ms |
16708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1993 ms |
16708 KB |
Output is correct |
2 |
Correct |
657 ms |
16708 KB |
Output is correct |
3 |
Correct |
260 ms |
16708 KB |
Output is correct |
4 |
Correct |
179 ms |
16708 KB |
Output is correct |
5 |
Correct |
266 ms |
16708 KB |
Output is correct |
6 |
Correct |
180 ms |
16708 KB |
Output is correct |
7 |
Correct |
1597 ms |
16708 KB |
Output is correct |
8 |
Correct |
956 ms |
16708 KB |
Output is correct |
9 |
Correct |
328 ms |
16708 KB |
Output is correct |
10 |
Correct |
52 ms |
16708 KB |
Output is correct |
11 |
Correct |
666 ms |
16708 KB |
Output is correct |
12 |
Correct |
39 ms |
16708 KB |
Output is correct |
13 |
Correct |
308 ms |
16708 KB |
Output is correct |
14 |
Correct |
1380 ms |
16708 KB |
Output is correct |
15 |
Correct |
802 ms |
16708 KB |
Output is correct |
16 |
Correct |
1262 ms |
16708 KB |
Output is correct |
17 |
Correct |
590 ms |
16708 KB |
Output is correct |
18 |
Correct |
562 ms |
16708 KB |
Output is correct |
19 |
Correct |
120 ms |
16708 KB |
Output is correct |
20 |
Correct |
713 ms |
16708 KB |
Output is correct |
21 |
Correct |
470 ms |
16708 KB |
Output is correct |
22 |
Correct |
1197 ms |
16708 KB |
Output is correct |
23 |
Correct |
450 ms |
16708 KB |
Output is correct |
24 |
Correct |
232 ms |
16708 KB |
Output is correct |
25 |
Correct |
247 ms |
16708 KB |
Output is correct |
26 |
Correct |
836 ms |
16708 KB |
Output is correct |
27 |
Correct |
78 ms |
16708 KB |
Output is correct |
28 |
Correct |
32 ms |
16708 KB |
Output is correct |
29 |
Execution timed out |
2000 ms |
16708 KB |
Program timed out |
30 |
Halted |
0 ms |
0 KB |
- |