#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;
const ll maxn=100005, Mod=1e9+7;
ll po[maxn], inv[maxn];
ll C(ll k, ll n){return po[n]*inv[k]%Mod*inv[n-k]%Mod;}
ll binpow(ll a, ll k)
{
ll ans=1;
for (; k; a=a*a%Mod, k>>=1)
if (k&1) ans=ans*a%Mod;
return ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n, k; cin >> n >> k;
for (ll i=0; i<maxn; i++)
po[i]=i?po[i-1]*i%Mod:1;
inv[maxn-1]=binpow(po[maxn-1], Mod-2);
for (ll i=maxn-2; i>=0; i--)
inv[i]=inv[i+1]*(i+1)%Mod;
ll ans=0;
for (ll i=0; i<k; i++)
ans+=(i&1?-1:1)*C(i, n+1)*binpow(k-i, n)%Mod;
cout << (ans%Mod+Mod)%Mod;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Correct |
2 ms |
1884 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
1884 KB |
Output is correct |
5 |
Correct |
2 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1884 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
2 ms |
1884 KB |
Output is correct |
10 |
Correct |
2 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Correct |
2 ms |
1884 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
1884 KB |
Output is correct |
5 |
Correct |
2 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1884 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
2 ms |
1884 KB |
Output is correct |
10 |
Correct |
2 ms |
1884 KB |
Output is correct |
11 |
Correct |
2 ms |
1884 KB |
Output is correct |
12 |
Correct |
2 ms |
1884 KB |
Output is correct |
13 |
Correct |
2 ms |
1884 KB |
Output is correct |
14 |
Correct |
2 ms |
1884 KB |
Output is correct |
15 |
Correct |
2 ms |
1884 KB |
Output is correct |
16 |
Correct |
2 ms |
1884 KB |
Output is correct |
17 |
Correct |
2 ms |
1832 KB |
Output is correct |
18 |
Correct |
2 ms |
1884 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
2 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Correct |
2 ms |
1884 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
1884 KB |
Output is correct |
5 |
Correct |
2 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1884 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
2 ms |
1884 KB |
Output is correct |
10 |
Correct |
2 ms |
1884 KB |
Output is correct |
11 |
Correct |
2 ms |
1884 KB |
Output is correct |
12 |
Correct |
2 ms |
1884 KB |
Output is correct |
13 |
Correct |
2 ms |
1884 KB |
Output is correct |
14 |
Correct |
2 ms |
1884 KB |
Output is correct |
15 |
Correct |
2 ms |
1884 KB |
Output is correct |
16 |
Correct |
2 ms |
1884 KB |
Output is correct |
17 |
Correct |
2 ms |
1832 KB |
Output is correct |
18 |
Correct |
2 ms |
1884 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
2 ms |
1884 KB |
Output is correct |
21 |
Correct |
2 ms |
1884 KB |
Output is correct |
22 |
Correct |
2 ms |
1884 KB |
Output is correct |
23 |
Correct |
2 ms |
1884 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Correct |
2 ms |
1884 KB |
Output is correct |
26 |
Correct |
2 ms |
1884 KB |
Output is correct |
27 |
Correct |
2 ms |
1824 KB |
Output is correct |
28 |
Correct |
2 ms |
1884 KB |
Output is correct |
29 |
Correct |
2 ms |
1884 KB |
Output is correct |
30 |
Correct |
2 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Correct |
2 ms |
1884 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
1884 KB |
Output is correct |
5 |
Correct |
2 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1884 KB |
Output is correct |
8 |
Correct |
2 ms |
1884 KB |
Output is correct |
9 |
Correct |
2 ms |
1884 KB |
Output is correct |
10 |
Correct |
2 ms |
1884 KB |
Output is correct |
11 |
Correct |
2 ms |
1884 KB |
Output is correct |
12 |
Correct |
2 ms |
1884 KB |
Output is correct |
13 |
Correct |
2 ms |
1884 KB |
Output is correct |
14 |
Correct |
2 ms |
1884 KB |
Output is correct |
15 |
Correct |
2 ms |
1884 KB |
Output is correct |
16 |
Correct |
2 ms |
1884 KB |
Output is correct |
17 |
Correct |
2 ms |
1832 KB |
Output is correct |
18 |
Correct |
2 ms |
1884 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
2 ms |
1884 KB |
Output is correct |
21 |
Correct |
2 ms |
1884 KB |
Output is correct |
22 |
Correct |
2 ms |
1884 KB |
Output is correct |
23 |
Correct |
2 ms |
1884 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Correct |
2 ms |
1884 KB |
Output is correct |
26 |
Correct |
2 ms |
1884 KB |
Output is correct |
27 |
Correct |
2 ms |
1824 KB |
Output is correct |
28 |
Correct |
2 ms |
1884 KB |
Output is correct |
29 |
Correct |
2 ms |
1884 KB |
Output is correct |
30 |
Correct |
2 ms |
1884 KB |
Output is correct |
31 |
Correct |
2 ms |
1884 KB |
Output is correct |
32 |
Correct |
2 ms |
1884 KB |
Output is correct |
33 |
Correct |
2 ms |
1884 KB |
Output is correct |
34 |
Correct |
3 ms |
1884 KB |
Output is correct |
35 |
Correct |
7 ms |
1976 KB |
Output is correct |
36 |
Correct |
8 ms |
2136 KB |
Output is correct |
37 |
Correct |
8 ms |
1884 KB |
Output is correct |
38 |
Correct |
2 ms |
1848 KB |
Output is correct |
39 |
Correct |
4 ms |
1884 KB |
Output is correct |
40 |
Correct |
5 ms |
1884 KB |
Output is correct |