# include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 2;
long long binpow(long long a, long long n){
long long res = 1;
while(n){
if(n & 1)
res = (res * a) % mod;
a = (a * a) % mod;
n >>= 1;
}
return res;
}
long long n, k, f[N], fi[N];
long long cnk(long long n, long long k){
return ((f[n] * fi[n - k]) % mod * fi[k]) % mod;
}
int main(){
f[0] = 1;
fi[0] = binpow(f[0], mod - 2);
for(long long i = 1; i < N; i ++){
f[i] = (f[i - 1] * i) % mod;
fi[i] = binpow(f[i], mod - 2);
}
scanf("%lld %lld", &n, &k);
long long ans = 0;
for(long long i = 0; i <= k; i ++){
if(i & 1){
ans -= (cnk(n + 1, i) * binpow(k - i, n)) % mod;
if(ans < 0) ans += mod;
}
else {
ans += (cnk(n + 1, i) * binpow(k - i, n)) % mod;
if(ans > mod) ans -= mod;
}
}
printf("%lld\n", ans);
return 0;
}
Compilation message
asceticism.cpp: In function 'int main()':
asceticism.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &n, &k);
~~~~~^~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1784 KB |
Output is correct |
2 |
Correct |
20 ms |
1896 KB |
Output is correct |
3 |
Correct |
24 ms |
1972 KB |
Output is correct |
4 |
Correct |
22 ms |
2012 KB |
Output is correct |
5 |
Correct |
22 ms |
2124 KB |
Output is correct |
6 |
Correct |
21 ms |
2124 KB |
Output is correct |
7 |
Correct |
23 ms |
2124 KB |
Output is correct |
8 |
Correct |
22 ms |
2208 KB |
Output is correct |
9 |
Correct |
23 ms |
2208 KB |
Output is correct |
10 |
Correct |
22 ms |
2208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1784 KB |
Output is correct |
2 |
Correct |
20 ms |
1896 KB |
Output is correct |
3 |
Correct |
24 ms |
1972 KB |
Output is correct |
4 |
Correct |
22 ms |
2012 KB |
Output is correct |
5 |
Correct |
22 ms |
2124 KB |
Output is correct |
6 |
Correct |
21 ms |
2124 KB |
Output is correct |
7 |
Correct |
23 ms |
2124 KB |
Output is correct |
8 |
Correct |
22 ms |
2208 KB |
Output is correct |
9 |
Correct |
23 ms |
2208 KB |
Output is correct |
10 |
Correct |
22 ms |
2208 KB |
Output is correct |
11 |
Correct |
23 ms |
2208 KB |
Output is correct |
12 |
Correct |
21 ms |
2208 KB |
Output is correct |
13 |
Correct |
22 ms |
2208 KB |
Output is correct |
14 |
Correct |
27 ms |
2208 KB |
Output is correct |
15 |
Correct |
23 ms |
2208 KB |
Output is correct |
16 |
Correct |
21 ms |
2208 KB |
Output is correct |
17 |
Correct |
22 ms |
2268 KB |
Output is correct |
18 |
Correct |
22 ms |
2268 KB |
Output is correct |
19 |
Correct |
20 ms |
2268 KB |
Output is correct |
20 |
Correct |
22 ms |
2268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1784 KB |
Output is correct |
2 |
Correct |
20 ms |
1896 KB |
Output is correct |
3 |
Correct |
24 ms |
1972 KB |
Output is correct |
4 |
Correct |
22 ms |
2012 KB |
Output is correct |
5 |
Correct |
22 ms |
2124 KB |
Output is correct |
6 |
Correct |
21 ms |
2124 KB |
Output is correct |
7 |
Correct |
23 ms |
2124 KB |
Output is correct |
8 |
Correct |
22 ms |
2208 KB |
Output is correct |
9 |
Correct |
23 ms |
2208 KB |
Output is correct |
10 |
Correct |
22 ms |
2208 KB |
Output is correct |
11 |
Correct |
23 ms |
2208 KB |
Output is correct |
12 |
Correct |
21 ms |
2208 KB |
Output is correct |
13 |
Correct |
22 ms |
2208 KB |
Output is correct |
14 |
Correct |
27 ms |
2208 KB |
Output is correct |
15 |
Correct |
23 ms |
2208 KB |
Output is correct |
16 |
Correct |
21 ms |
2208 KB |
Output is correct |
17 |
Correct |
22 ms |
2268 KB |
Output is correct |
18 |
Correct |
22 ms |
2268 KB |
Output is correct |
19 |
Correct |
20 ms |
2268 KB |
Output is correct |
20 |
Correct |
22 ms |
2268 KB |
Output is correct |
21 |
Correct |
22 ms |
2268 KB |
Output is correct |
22 |
Correct |
21 ms |
2268 KB |
Output is correct |
23 |
Correct |
21 ms |
2268 KB |
Output is correct |
24 |
Correct |
22 ms |
2296 KB |
Output is correct |
25 |
Correct |
23 ms |
2296 KB |
Output is correct |
26 |
Correct |
22 ms |
2296 KB |
Output is correct |
27 |
Correct |
23 ms |
2296 KB |
Output is correct |
28 |
Correct |
22 ms |
2296 KB |
Output is correct |
29 |
Correct |
23 ms |
2296 KB |
Output is correct |
30 |
Correct |
22 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1784 KB |
Output is correct |
2 |
Correct |
20 ms |
1896 KB |
Output is correct |
3 |
Correct |
24 ms |
1972 KB |
Output is correct |
4 |
Correct |
22 ms |
2012 KB |
Output is correct |
5 |
Correct |
22 ms |
2124 KB |
Output is correct |
6 |
Correct |
21 ms |
2124 KB |
Output is correct |
7 |
Correct |
23 ms |
2124 KB |
Output is correct |
8 |
Correct |
22 ms |
2208 KB |
Output is correct |
9 |
Correct |
23 ms |
2208 KB |
Output is correct |
10 |
Correct |
22 ms |
2208 KB |
Output is correct |
11 |
Correct |
23 ms |
2208 KB |
Output is correct |
12 |
Correct |
21 ms |
2208 KB |
Output is correct |
13 |
Correct |
22 ms |
2208 KB |
Output is correct |
14 |
Correct |
27 ms |
2208 KB |
Output is correct |
15 |
Correct |
23 ms |
2208 KB |
Output is correct |
16 |
Correct |
21 ms |
2208 KB |
Output is correct |
17 |
Correct |
22 ms |
2268 KB |
Output is correct |
18 |
Correct |
22 ms |
2268 KB |
Output is correct |
19 |
Correct |
20 ms |
2268 KB |
Output is correct |
20 |
Correct |
22 ms |
2268 KB |
Output is correct |
21 |
Correct |
22 ms |
2268 KB |
Output is correct |
22 |
Correct |
21 ms |
2268 KB |
Output is correct |
23 |
Correct |
21 ms |
2268 KB |
Output is correct |
24 |
Correct |
22 ms |
2296 KB |
Output is correct |
25 |
Correct |
23 ms |
2296 KB |
Output is correct |
26 |
Correct |
22 ms |
2296 KB |
Output is correct |
27 |
Correct |
23 ms |
2296 KB |
Output is correct |
28 |
Correct |
22 ms |
2296 KB |
Output is correct |
29 |
Correct |
23 ms |
2296 KB |
Output is correct |
30 |
Correct |
22 ms |
2296 KB |
Output is correct |
31 |
Correct |
21 ms |
2296 KB |
Output is correct |
32 |
Correct |
21 ms |
2296 KB |
Output is correct |
33 |
Correct |
24 ms |
2396 KB |
Output is correct |
34 |
Correct |
23 ms |
2396 KB |
Output is correct |
35 |
Correct |
29 ms |
2396 KB |
Output is correct |
36 |
Correct |
30 ms |
2396 KB |
Output is correct |
37 |
Correct |
37 ms |
2396 KB |
Output is correct |
38 |
Correct |
24 ms |
2396 KB |
Output is correct |
39 |
Correct |
25 ms |
2396 KB |
Output is correct |
40 |
Correct |
26 ms |
2396 KB |
Output is correct |