// ~ Be Name Khoda ~
#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,O3")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 5e5 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
ll fact[maxn];
inline void fix(int &a){
if(a < 0)
a += mod;
if(a >= mod)
a -= mod;
}
inline ll pw(ll a, ll b){
ll ret = 1;
for(; b; b >>= 1, a = a * a % mod)
if(b & 1) ret = ret * a % mod;
return ret;
}
inline ll ent(int n, int r){
return fact[n] * pw(fact[r] * fact[n - r] % mod, mod - 2) % mod;
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
fact[0] = 1;
for(int i = 1; i < maxn; i++)
fact[i] = i * fact[i - 1] % mod;
int n, k; cin >> n >> k;
int ans = 0;
for(int i = 0; i < k; i++){
fix(ans += pw(k - i, n) * ent(n + 1, i) % mod * (i % 2 ? -1 : 1));
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
8020 KB |
Output is correct |
2 |
Correct |
8 ms |
8148 KB |
Output is correct |
3 |
Correct |
9 ms |
8048 KB |
Output is correct |
4 |
Correct |
8 ms |
8148 KB |
Output is correct |
5 |
Correct |
8 ms |
8052 KB |
Output is correct |
6 |
Correct |
9 ms |
8148 KB |
Output is correct |
7 |
Correct |
9 ms |
8140 KB |
Output is correct |
8 |
Correct |
8 ms |
8060 KB |
Output is correct |
9 |
Correct |
8 ms |
8148 KB |
Output is correct |
10 |
Correct |
9 ms |
8020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
8020 KB |
Output is correct |
2 |
Correct |
8 ms |
8148 KB |
Output is correct |
3 |
Correct |
9 ms |
8048 KB |
Output is correct |
4 |
Correct |
8 ms |
8148 KB |
Output is correct |
5 |
Correct |
8 ms |
8052 KB |
Output is correct |
6 |
Correct |
9 ms |
8148 KB |
Output is correct |
7 |
Correct |
9 ms |
8140 KB |
Output is correct |
8 |
Correct |
8 ms |
8060 KB |
Output is correct |
9 |
Correct |
8 ms |
8148 KB |
Output is correct |
10 |
Correct |
9 ms |
8020 KB |
Output is correct |
11 |
Correct |
8 ms |
8148 KB |
Output is correct |
12 |
Correct |
8 ms |
8148 KB |
Output is correct |
13 |
Correct |
8 ms |
8052 KB |
Output is correct |
14 |
Correct |
9 ms |
8148 KB |
Output is correct |
15 |
Correct |
8 ms |
8144 KB |
Output is correct |
16 |
Correct |
8 ms |
8020 KB |
Output is correct |
17 |
Correct |
8 ms |
8148 KB |
Output is correct |
18 |
Correct |
9 ms |
8048 KB |
Output is correct |
19 |
Correct |
9 ms |
8020 KB |
Output is correct |
20 |
Correct |
10 ms |
8088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
8020 KB |
Output is correct |
2 |
Correct |
8 ms |
8148 KB |
Output is correct |
3 |
Correct |
9 ms |
8048 KB |
Output is correct |
4 |
Correct |
8 ms |
8148 KB |
Output is correct |
5 |
Correct |
8 ms |
8052 KB |
Output is correct |
6 |
Correct |
9 ms |
8148 KB |
Output is correct |
7 |
Correct |
9 ms |
8140 KB |
Output is correct |
8 |
Correct |
8 ms |
8060 KB |
Output is correct |
9 |
Correct |
8 ms |
8148 KB |
Output is correct |
10 |
Correct |
9 ms |
8020 KB |
Output is correct |
11 |
Correct |
8 ms |
8148 KB |
Output is correct |
12 |
Correct |
8 ms |
8148 KB |
Output is correct |
13 |
Correct |
8 ms |
8052 KB |
Output is correct |
14 |
Correct |
9 ms |
8148 KB |
Output is correct |
15 |
Correct |
8 ms |
8144 KB |
Output is correct |
16 |
Correct |
8 ms |
8020 KB |
Output is correct |
17 |
Correct |
8 ms |
8148 KB |
Output is correct |
18 |
Correct |
9 ms |
8048 KB |
Output is correct |
19 |
Correct |
9 ms |
8020 KB |
Output is correct |
20 |
Correct |
10 ms |
8088 KB |
Output is correct |
21 |
Correct |
8 ms |
8124 KB |
Output is correct |
22 |
Correct |
8 ms |
8020 KB |
Output is correct |
23 |
Correct |
8 ms |
8080 KB |
Output is correct |
24 |
Correct |
8 ms |
8152 KB |
Output is correct |
25 |
Correct |
8 ms |
8148 KB |
Output is correct |
26 |
Correct |
9 ms |
8096 KB |
Output is correct |
27 |
Correct |
9 ms |
8064 KB |
Output is correct |
28 |
Correct |
8 ms |
8048 KB |
Output is correct |
29 |
Correct |
9 ms |
8148 KB |
Output is correct |
30 |
Correct |
10 ms |
8148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
8020 KB |
Output is correct |
2 |
Correct |
8 ms |
8148 KB |
Output is correct |
3 |
Correct |
9 ms |
8048 KB |
Output is correct |
4 |
Correct |
8 ms |
8148 KB |
Output is correct |
5 |
Correct |
8 ms |
8052 KB |
Output is correct |
6 |
Correct |
9 ms |
8148 KB |
Output is correct |
7 |
Correct |
9 ms |
8140 KB |
Output is correct |
8 |
Correct |
8 ms |
8060 KB |
Output is correct |
9 |
Correct |
8 ms |
8148 KB |
Output is correct |
10 |
Correct |
9 ms |
8020 KB |
Output is correct |
11 |
Correct |
8 ms |
8148 KB |
Output is correct |
12 |
Correct |
8 ms |
8148 KB |
Output is correct |
13 |
Correct |
8 ms |
8052 KB |
Output is correct |
14 |
Correct |
9 ms |
8148 KB |
Output is correct |
15 |
Correct |
8 ms |
8144 KB |
Output is correct |
16 |
Correct |
8 ms |
8020 KB |
Output is correct |
17 |
Correct |
8 ms |
8148 KB |
Output is correct |
18 |
Correct |
9 ms |
8048 KB |
Output is correct |
19 |
Correct |
9 ms |
8020 KB |
Output is correct |
20 |
Correct |
10 ms |
8088 KB |
Output is correct |
21 |
Correct |
8 ms |
8124 KB |
Output is correct |
22 |
Correct |
8 ms |
8020 KB |
Output is correct |
23 |
Correct |
8 ms |
8080 KB |
Output is correct |
24 |
Correct |
8 ms |
8152 KB |
Output is correct |
25 |
Correct |
8 ms |
8148 KB |
Output is correct |
26 |
Correct |
9 ms |
8096 KB |
Output is correct |
27 |
Correct |
9 ms |
8064 KB |
Output is correct |
28 |
Correct |
8 ms |
8048 KB |
Output is correct |
29 |
Correct |
9 ms |
8148 KB |
Output is correct |
30 |
Correct |
10 ms |
8148 KB |
Output is correct |
31 |
Correct |
9 ms |
8152 KB |
Output is correct |
32 |
Correct |
8 ms |
8020 KB |
Output is correct |
33 |
Correct |
9 ms |
8020 KB |
Output is correct |
34 |
Correct |
11 ms |
8152 KB |
Output is correct |
35 |
Correct |
25 ms |
8020 KB |
Output is correct |
36 |
Correct |
28 ms |
8020 KB |
Output is correct |
37 |
Correct |
31 ms |
8152 KB |
Output is correct |
38 |
Correct |
11 ms |
8020 KB |
Output is correct |
39 |
Correct |
15 ms |
8148 KB |
Output is correct |
40 |
Correct |
17 ms |
8144 KB |
Output is correct |