#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);
cout << (ans%Mod+Mod)%Mod;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2136 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
2136 KB |
Output is correct |
5 |
Correct |
3 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1880 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 |
2136 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
2136 KB |
Output is correct |
5 |
Correct |
3 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1880 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 |
1880 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 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 |
1884 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 |
2136 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
2136 KB |
Output is correct |
5 |
Correct |
3 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1880 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 |
1880 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 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 |
1884 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 |
1892 KB |
Output is correct |
23 |
Correct |
2 ms |
1884 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Incorrect |
2 ms |
1912 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2136 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
3 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
2136 KB |
Output is correct |
5 |
Correct |
3 ms |
1884 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1880 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 |
1880 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 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 |
1884 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 |
1892 KB |
Output is correct |
23 |
Correct |
2 ms |
1884 KB |
Output is correct |
24 |
Correct |
2 ms |
1884 KB |
Output is correct |
25 |
Incorrect |
2 ms |
1912 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |