#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
const ll MOD = 1e9 + 7;
ll pw(ll x, ll y){
ll res = 1;
while(y){
if(y & 1)res = res * x % MOD;
x = x * x % MOD;
y >>= 1;
}
return res;
}
int main(){
ll f = 1;
int n, k;
scanf("%d%d", &n, &k);
if(n == k){
printf("0");
return 0;
}
for(int i=1;i<=n+1;i++)f = i * f % MOD;
ll s = 0;
for(int i=k+1;i<=n;i++){
s += (n+1-i) * pw(i+1, MOD-2);
s %= MOD;
}
f = f * s % MOD;
printf("%lld", f);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
0 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
0 ms |
1720 KB |
Output is correct |
6 |
Correct |
0 ms |
1720 KB |
Output is correct |
7 |
Correct |
0 ms |
1720 KB |
Output is correct |
8 |
Correct |
0 ms |
1720 KB |
Output is correct |
9 |
Correct |
0 ms |
1720 KB |
Output is correct |
10 |
Correct |
0 ms |
1720 KB |
Output is correct |
11 |
Correct |
0 ms |
1720 KB |
Output is correct |
12 |
Correct |
0 ms |
1720 KB |
Output is correct |
13 |
Correct |
0 ms |
1720 KB |
Output is correct |
14 |
Correct |
0 ms |
1720 KB |
Output is correct |
15 |
Correct |
0 ms |
1720 KB |
Output is correct |
16 |
Correct |
0 ms |
1720 KB |
Output is correct |
17 |
Correct |
0 ms |
1720 KB |
Output is correct |
18 |
Correct |
0 ms |
1720 KB |
Output is correct |
19 |
Correct |
0 ms |
1720 KB |
Output is correct |
20 |
Correct |
0 ms |
1720 KB |
Output is correct |
21 |
Correct |
0 ms |
1720 KB |
Output is correct |
22 |
Correct |
0 ms |
1720 KB |
Output is correct |
23 |
Correct |
0 ms |
1720 KB |
Output is correct |
24 |
Correct |
0 ms |
1720 KB |
Output is correct |
25 |
Correct |
0 ms |
1720 KB |
Output is correct |
26 |
Correct |
0 ms |
1720 KB |
Output is correct |
27 |
Correct |
0 ms |
1720 KB |
Output is correct |
28 |
Correct |
0 ms |
1720 KB |
Output is correct |
29 |
Correct |
0 ms |
1720 KB |
Output is correct |
30 |
Correct |
0 ms |
1720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
231 ms |
1720 KB |
Output is correct |
2 |
Correct |
79 ms |
1720 KB |
Output is correct |
3 |
Correct |
34 ms |
1720 KB |
Output is correct |
4 |
Correct |
21 ms |
1720 KB |
Output is correct |
5 |
Correct |
31 ms |
1720 KB |
Output is correct |
6 |
Correct |
25 ms |
1720 KB |
Output is correct |
7 |
Correct |
186 ms |
1720 KB |
Output is correct |
8 |
Correct |
112 ms |
1720 KB |
Output is correct |
9 |
Correct |
39 ms |
1720 KB |
Output is correct |
10 |
Correct |
3 ms |
1720 KB |
Output is correct |
11 |
Correct |
77 ms |
1720 KB |
Output is correct |
12 |
Correct |
8 ms |
1720 KB |
Output is correct |
13 |
Correct |
39 ms |
1720 KB |
Output is correct |
14 |
Correct |
161 ms |
1720 KB |
Output is correct |
15 |
Correct |
94 ms |
1720 KB |
Output is correct |
16 |
Correct |
147 ms |
1720 KB |
Output is correct |
17 |
Correct |
67 ms |
1720 KB |
Output is correct |
18 |
Correct |
66 ms |
1720 KB |
Output is correct |
19 |
Correct |
13 ms |
1720 KB |
Output is correct |
20 |
Correct |
86 ms |
1720 KB |
Output is correct |
21 |
Correct |
55 ms |
1720 KB |
Output is correct |
22 |
Correct |
140 ms |
1720 KB |
Output is correct |
23 |
Correct |
55 ms |
1720 KB |
Output is correct |
24 |
Correct |
27 ms |
1720 KB |
Output is correct |
25 |
Correct |
32 ms |
1720 KB |
Output is correct |
26 |
Correct |
94 ms |
1720 KB |
Output is correct |
27 |
Correct |
11 ms |
1720 KB |
Output is correct |
28 |
Correct |
6 ms |
1720 KB |
Output is correct |
29 |
Correct |
259 ms |
1720 KB |
Output is correct |
30 |
Correct |
260 ms |
1720 KB |
Output is correct |