#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define random rand() ^ (rand() << 5)
const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
int mod = (int)1e9 + 7;
ll fact[N];
ll mult(ll a, ll b) {
return a * b % mod;
}
void precalc() {
fact[0] = 1;
for (ll i = 1; i < N; i++) {
fact[i] = mult(fact[i - 1], i);
}
}
ll binpow(ll a, int n) {
ll res = 1;
while (n > 0) {
if (n & 1) {
res = mult(res, a);
}
a = mult(a, a);
n >>= 1;
}
return res;
}
ll cnk(ll n, ll k) {
if (k > n) return 0;
return mult(mult(fact[n], binpow(fact[k], mod - 2)), binpow(fact[n - k], mod - 2));
}
int n, m;
main() {
precalc();
scanf("%d %d", &n, &m);
m--;
ll ans = 0;
for (int k = 0; k <= m + 1; k++) {
if (k & 1) {
ans -= mult(cnk(n + 1, k), binpow(m + 1 - k, n));
} else {
ans += mult(cnk(n + 1, k), binpow(m + 1 - k, n));
}
}
cout << ans;
}
Compilation message
asceticism.cpp:55:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
asceticism.cpp: In function 'int main()':
asceticism.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &m);
~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1132 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1132 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1132 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1132 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |