#include <cstdio>
#include <cstring>
#include <vector>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef vector < int > vi;
const int N = 1e5 + 500;
const int MOD = 1e9 + 7;
inline int add(int A,int B){
if(A + B >= MOD) return A + B - MOD;
return A + B;
}
inline int mul(int A,int B){
return (ll)A * B % MOD;
}
inline int sub(int A,int B){
if(A - B < 0) return A - B + MOD;
return A - B;
}
inline int pot(int A,int B){
int ret = 1, bas = A;
for(;B;B >>= 1){
if(B&1) ret = mul(ret, bas);
bas = mul(bas, bas);
}
return ret;
}
int fak[N], inv[N], n, k;
void precompute(){
fak[0] = 1; inv[0] = 1;
for(int i = 1;i < N;i++){
fak[i] = mul(fak[i - 1], i);
inv[i] = pot(fak[i], MOD -2);
}
}
int choose(int n,int k){
return mul(fak[n], mul(inv[k], inv[n - k]));
}
int main(){
precompute();
scanf("%d%d", &n, &k);
int ret = 0;
for(int i = 0;i <= k;i++){
ret = add(ret, mul(pot(MOD - 1, i), mul(choose(n + 1, i), pot(k - i, n))));
}
printf("%d\n", ret);
return 0;
}
Compilation message
asceticism.cpp: In function 'int main()':
asceticism.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &k);
~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1152 KB |
Output is correct |
2 |
Correct |
23 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
1024 KB |
Output is correct |
4 |
Correct |
22 ms |
1024 KB |
Output is correct |
5 |
Correct |
23 ms |
1152 KB |
Output is correct |
6 |
Correct |
22 ms |
1152 KB |
Output is correct |
7 |
Correct |
22 ms |
1024 KB |
Output is correct |
8 |
Correct |
22 ms |
896 KB |
Output is correct |
9 |
Correct |
23 ms |
1152 KB |
Output is correct |
10 |
Correct |
22 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1152 KB |
Output is correct |
2 |
Correct |
23 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
1024 KB |
Output is correct |
4 |
Correct |
22 ms |
1024 KB |
Output is correct |
5 |
Correct |
23 ms |
1152 KB |
Output is correct |
6 |
Correct |
22 ms |
1152 KB |
Output is correct |
7 |
Correct |
22 ms |
1024 KB |
Output is correct |
8 |
Correct |
22 ms |
896 KB |
Output is correct |
9 |
Correct |
23 ms |
1152 KB |
Output is correct |
10 |
Correct |
22 ms |
1024 KB |
Output is correct |
11 |
Correct |
23 ms |
1128 KB |
Output is correct |
12 |
Correct |
25 ms |
1024 KB |
Output is correct |
13 |
Correct |
23 ms |
1152 KB |
Output is correct |
14 |
Correct |
23 ms |
1024 KB |
Output is correct |
15 |
Correct |
23 ms |
1024 KB |
Output is correct |
16 |
Correct |
22 ms |
1024 KB |
Output is correct |
17 |
Correct |
22 ms |
1024 KB |
Output is correct |
18 |
Correct |
23 ms |
1024 KB |
Output is correct |
19 |
Correct |
24 ms |
1280 KB |
Output is correct |
20 |
Correct |
23 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1152 KB |
Output is correct |
2 |
Correct |
23 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
1024 KB |
Output is correct |
4 |
Correct |
22 ms |
1024 KB |
Output is correct |
5 |
Correct |
23 ms |
1152 KB |
Output is correct |
6 |
Correct |
22 ms |
1152 KB |
Output is correct |
7 |
Correct |
22 ms |
1024 KB |
Output is correct |
8 |
Correct |
22 ms |
896 KB |
Output is correct |
9 |
Correct |
23 ms |
1152 KB |
Output is correct |
10 |
Correct |
22 ms |
1024 KB |
Output is correct |
11 |
Correct |
23 ms |
1128 KB |
Output is correct |
12 |
Correct |
25 ms |
1024 KB |
Output is correct |
13 |
Correct |
23 ms |
1152 KB |
Output is correct |
14 |
Correct |
23 ms |
1024 KB |
Output is correct |
15 |
Correct |
23 ms |
1024 KB |
Output is correct |
16 |
Correct |
22 ms |
1024 KB |
Output is correct |
17 |
Correct |
22 ms |
1024 KB |
Output is correct |
18 |
Correct |
23 ms |
1024 KB |
Output is correct |
19 |
Correct |
24 ms |
1280 KB |
Output is correct |
20 |
Correct |
23 ms |
1024 KB |
Output is correct |
21 |
Correct |
22 ms |
1024 KB |
Output is correct |
22 |
Correct |
24 ms |
1024 KB |
Output is correct |
23 |
Correct |
22 ms |
1024 KB |
Output is correct |
24 |
Correct |
23 ms |
1152 KB |
Output is correct |
25 |
Correct |
27 ms |
1140 KB |
Output is correct |
26 |
Correct |
23 ms |
1024 KB |
Output is correct |
27 |
Correct |
23 ms |
1152 KB |
Output is correct |
28 |
Correct |
23 ms |
1152 KB |
Output is correct |
29 |
Correct |
22 ms |
1024 KB |
Output is correct |
30 |
Correct |
23 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1152 KB |
Output is correct |
2 |
Correct |
23 ms |
1024 KB |
Output is correct |
3 |
Correct |
23 ms |
1024 KB |
Output is correct |
4 |
Correct |
22 ms |
1024 KB |
Output is correct |
5 |
Correct |
23 ms |
1152 KB |
Output is correct |
6 |
Correct |
22 ms |
1152 KB |
Output is correct |
7 |
Correct |
22 ms |
1024 KB |
Output is correct |
8 |
Correct |
22 ms |
896 KB |
Output is correct |
9 |
Correct |
23 ms |
1152 KB |
Output is correct |
10 |
Correct |
22 ms |
1024 KB |
Output is correct |
11 |
Correct |
23 ms |
1128 KB |
Output is correct |
12 |
Correct |
25 ms |
1024 KB |
Output is correct |
13 |
Correct |
23 ms |
1152 KB |
Output is correct |
14 |
Correct |
23 ms |
1024 KB |
Output is correct |
15 |
Correct |
23 ms |
1024 KB |
Output is correct |
16 |
Correct |
22 ms |
1024 KB |
Output is correct |
17 |
Correct |
22 ms |
1024 KB |
Output is correct |
18 |
Correct |
23 ms |
1024 KB |
Output is correct |
19 |
Correct |
24 ms |
1280 KB |
Output is correct |
20 |
Correct |
23 ms |
1024 KB |
Output is correct |
21 |
Correct |
22 ms |
1024 KB |
Output is correct |
22 |
Correct |
24 ms |
1024 KB |
Output is correct |
23 |
Correct |
22 ms |
1024 KB |
Output is correct |
24 |
Correct |
23 ms |
1152 KB |
Output is correct |
25 |
Correct |
27 ms |
1140 KB |
Output is correct |
26 |
Correct |
23 ms |
1024 KB |
Output is correct |
27 |
Correct |
23 ms |
1152 KB |
Output is correct |
28 |
Correct |
23 ms |
1152 KB |
Output is correct |
29 |
Correct |
22 ms |
1024 KB |
Output is correct |
30 |
Correct |
23 ms |
1024 KB |
Output is correct |
31 |
Correct |
23 ms |
1152 KB |
Output is correct |
32 |
Correct |
24 ms |
1152 KB |
Output is correct |
33 |
Correct |
23 ms |
1024 KB |
Output is correct |
34 |
Correct |
26 ms |
1152 KB |
Output is correct |
35 |
Correct |
38 ms |
1024 KB |
Output is correct |
36 |
Correct |
40 ms |
1024 KB |
Output is correct |
37 |
Correct |
42 ms |
1024 KB |
Output is correct |
38 |
Correct |
25 ms |
1152 KB |
Output is correct |
39 |
Correct |
28 ms |
1024 KB |
Output is correct |
40 |
Correct |
30 ms |
1024 KB |
Output is correct |