#include <bits/stdc++.h>
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;
int n,m;
int f[N];
int ans;
int binpow (int a,int b) {
int res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
a %= inf;
res %= inf;
}
return (res % inf);
}
int cnk(int n,int k) {
return ((f[n] * binpow(f[n - k],inf - 2)) % inf * binpow(f[k],inf - 2) % inf);
}
int fun(int k) {
return ((cnk(n + 1,k) * binpow(m - k,n)) % inf);
}
main() {
f[0] = 1;
for (int i = 1; i <= N - 5; i ++)
f[i] = (f[i - 1] * i) % inf;
cin >> n >> m;
for (int i = 0; i <= m; i ++) {
if (i & 1)
ans = (ans + inf - fun(i)) % inf;
else
ans = (ans + fun(i)) % inf;
}
cout << ans << endl;
}
Compilation message
asceticism.cpp:38:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1144 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1196 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
3 ms |
1248 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1144 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1196 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
3 ms |
1248 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1280 KB |
Output is correct |
12 |
Correct |
3 ms |
1288 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
3 ms |
1408 KB |
Output is correct |
15 |
Correct |
3 ms |
1408 KB |
Output is correct |
16 |
Correct |
4 ms |
1460 KB |
Output is correct |
17 |
Correct |
3 ms |
1460 KB |
Output is correct |
18 |
Correct |
3 ms |
1460 KB |
Output is correct |
19 |
Correct |
3 ms |
1460 KB |
Output is correct |
20 |
Correct |
3 ms |
1460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1144 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1196 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
3 ms |
1248 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1280 KB |
Output is correct |
12 |
Correct |
3 ms |
1288 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
3 ms |
1408 KB |
Output is correct |
15 |
Correct |
3 ms |
1408 KB |
Output is correct |
16 |
Correct |
4 ms |
1460 KB |
Output is correct |
17 |
Correct |
3 ms |
1460 KB |
Output is correct |
18 |
Correct |
3 ms |
1460 KB |
Output is correct |
19 |
Correct |
3 ms |
1460 KB |
Output is correct |
20 |
Correct |
3 ms |
1460 KB |
Output is correct |
21 |
Correct |
3 ms |
1460 KB |
Output is correct |
22 |
Correct |
3 ms |
1460 KB |
Output is correct |
23 |
Correct |
3 ms |
1460 KB |
Output is correct |
24 |
Correct |
4 ms |
1460 KB |
Output is correct |
25 |
Correct |
3 ms |
1480 KB |
Output is correct |
26 |
Correct |
3 ms |
1480 KB |
Output is correct |
27 |
Correct |
4 ms |
1480 KB |
Output is correct |
28 |
Correct |
3 ms |
1480 KB |
Output is correct |
29 |
Correct |
3 ms |
1480 KB |
Output is correct |
30 |
Correct |
4 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1144 KB |
Output is correct |
2 |
Correct |
3 ms |
1144 KB |
Output is correct |
3 |
Correct |
3 ms |
1196 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
3 ms |
1248 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1280 KB |
Output is correct |
12 |
Correct |
3 ms |
1288 KB |
Output is correct |
13 |
Correct |
3 ms |
1408 KB |
Output is correct |
14 |
Correct |
3 ms |
1408 KB |
Output is correct |
15 |
Correct |
3 ms |
1408 KB |
Output is correct |
16 |
Correct |
4 ms |
1460 KB |
Output is correct |
17 |
Correct |
3 ms |
1460 KB |
Output is correct |
18 |
Correct |
3 ms |
1460 KB |
Output is correct |
19 |
Correct |
3 ms |
1460 KB |
Output is correct |
20 |
Correct |
3 ms |
1460 KB |
Output is correct |
21 |
Correct |
3 ms |
1460 KB |
Output is correct |
22 |
Correct |
3 ms |
1460 KB |
Output is correct |
23 |
Correct |
3 ms |
1460 KB |
Output is correct |
24 |
Correct |
4 ms |
1460 KB |
Output is correct |
25 |
Correct |
3 ms |
1480 KB |
Output is correct |
26 |
Correct |
3 ms |
1480 KB |
Output is correct |
27 |
Correct |
4 ms |
1480 KB |
Output is correct |
28 |
Correct |
3 ms |
1480 KB |
Output is correct |
29 |
Correct |
3 ms |
1480 KB |
Output is correct |
30 |
Correct |
4 ms |
1484 KB |
Output is correct |
31 |
Correct |
3 ms |
1484 KB |
Output is correct |
32 |
Correct |
3 ms |
1484 KB |
Output is correct |
33 |
Correct |
5 ms |
1484 KB |
Output is correct |
34 |
Correct |
11 ms |
1484 KB |
Output is correct |
35 |
Correct |
44 ms |
1484 KB |
Output is correct |
36 |
Correct |
47 ms |
1488 KB |
Output is correct |
37 |
Correct |
51 ms |
1488 KB |
Output is correct |
38 |
Correct |
9 ms |
1488 KB |
Output is correct |
39 |
Correct |
18 ms |
1488 KB |
Output is correct |
40 |
Correct |
22 ms |
1488 KB |
Output is correct |