#define local
#ifndef local
#include ""
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
return abs(temp) + l;
}
#ifdef local
int n, k;
int fac[N], invfac[N];
int c(int n, int k){
int temp = (fac[n] * invfac[k]) % mod;
//cout << temp << "\n";
temp = (temp * invfac[n - k]) % mod;
//cout << temp << "\n";
return temp;
}
int binpw(int base, int pw){
int ans = 1;
while(pw){
if(pw & 1) ans = (ans * base) % mod;
base = (base * base) % mod;
pw >>= 1;
}
return ans;
}
void process(){
cin >> n >> k;
//dp[1][1] = 1;
fac[0] = invfac[0] = 1;
for(int i = 1; i <= 100000; i++){
fac[i] = (fac[i - 1] * i) % mod;
invfac[i] = (invfac[i - 1] * binpw(i, mod - 2)) % mod;
//cout << fac[i] << " " << invfac[i] << "\n";
}
int answer = 0;
k--;
for(int i = 0; i <= k + 1; i++){
int sig = (i & 1 ? -1 : 1);
sig = sig * c(n + 1, i) * binpw(k - i + 1, n);
//cout << c(n + 1, i) << " " << binpw(k - i + 1, n) << "\n";
//cout << sig << "\n";
sig = ((sig % mod) + mod) % mod;
answer = (answer + sig) % mod;
}
cout << answer << "\n";
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
process();
}
#endif
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1840 KB |
Output is correct |
2 |
Correct |
12 ms |
1876 KB |
Output is correct |
3 |
Correct |
12 ms |
1864 KB |
Output is correct |
4 |
Correct |
13 ms |
1788 KB |
Output is correct |
5 |
Correct |
12 ms |
1848 KB |
Output is correct |
6 |
Correct |
13 ms |
1836 KB |
Output is correct |
7 |
Correct |
13 ms |
1876 KB |
Output is correct |
8 |
Correct |
12 ms |
1876 KB |
Output is correct |
9 |
Correct |
12 ms |
1808 KB |
Output is correct |
10 |
Correct |
12 ms |
1876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1840 KB |
Output is correct |
2 |
Correct |
12 ms |
1876 KB |
Output is correct |
3 |
Correct |
12 ms |
1864 KB |
Output is correct |
4 |
Correct |
13 ms |
1788 KB |
Output is correct |
5 |
Correct |
12 ms |
1848 KB |
Output is correct |
6 |
Correct |
13 ms |
1836 KB |
Output is correct |
7 |
Correct |
13 ms |
1876 KB |
Output is correct |
8 |
Correct |
12 ms |
1876 KB |
Output is correct |
9 |
Correct |
12 ms |
1808 KB |
Output is correct |
10 |
Correct |
12 ms |
1876 KB |
Output is correct |
11 |
Correct |
12 ms |
1872 KB |
Output is correct |
12 |
Correct |
12 ms |
1816 KB |
Output is correct |
13 |
Correct |
12 ms |
1892 KB |
Output is correct |
14 |
Correct |
12 ms |
1908 KB |
Output is correct |
15 |
Correct |
12 ms |
1836 KB |
Output is correct |
16 |
Correct |
13 ms |
1792 KB |
Output is correct |
17 |
Correct |
12 ms |
1876 KB |
Output is correct |
18 |
Correct |
12 ms |
1876 KB |
Output is correct |
19 |
Correct |
12 ms |
1856 KB |
Output is correct |
20 |
Correct |
12 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1840 KB |
Output is correct |
2 |
Correct |
12 ms |
1876 KB |
Output is correct |
3 |
Correct |
12 ms |
1864 KB |
Output is correct |
4 |
Correct |
13 ms |
1788 KB |
Output is correct |
5 |
Correct |
12 ms |
1848 KB |
Output is correct |
6 |
Correct |
13 ms |
1836 KB |
Output is correct |
7 |
Correct |
13 ms |
1876 KB |
Output is correct |
8 |
Correct |
12 ms |
1876 KB |
Output is correct |
9 |
Correct |
12 ms |
1808 KB |
Output is correct |
10 |
Correct |
12 ms |
1876 KB |
Output is correct |
11 |
Correct |
12 ms |
1872 KB |
Output is correct |
12 |
Correct |
12 ms |
1816 KB |
Output is correct |
13 |
Correct |
12 ms |
1892 KB |
Output is correct |
14 |
Correct |
12 ms |
1908 KB |
Output is correct |
15 |
Correct |
12 ms |
1836 KB |
Output is correct |
16 |
Correct |
13 ms |
1792 KB |
Output is correct |
17 |
Correct |
12 ms |
1876 KB |
Output is correct |
18 |
Correct |
12 ms |
1876 KB |
Output is correct |
19 |
Correct |
12 ms |
1856 KB |
Output is correct |
20 |
Correct |
12 ms |
1864 KB |
Output is correct |
21 |
Correct |
12 ms |
1860 KB |
Output is correct |
22 |
Correct |
12 ms |
1800 KB |
Output is correct |
23 |
Correct |
13 ms |
1876 KB |
Output is correct |
24 |
Correct |
12 ms |
1876 KB |
Output is correct |
25 |
Correct |
13 ms |
1824 KB |
Output is correct |
26 |
Correct |
12 ms |
1876 KB |
Output is correct |
27 |
Correct |
12 ms |
1784 KB |
Output is correct |
28 |
Correct |
12 ms |
1876 KB |
Output is correct |
29 |
Correct |
12 ms |
1792 KB |
Output is correct |
30 |
Correct |
12 ms |
1876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1840 KB |
Output is correct |
2 |
Correct |
12 ms |
1876 KB |
Output is correct |
3 |
Correct |
12 ms |
1864 KB |
Output is correct |
4 |
Correct |
13 ms |
1788 KB |
Output is correct |
5 |
Correct |
12 ms |
1848 KB |
Output is correct |
6 |
Correct |
13 ms |
1836 KB |
Output is correct |
7 |
Correct |
13 ms |
1876 KB |
Output is correct |
8 |
Correct |
12 ms |
1876 KB |
Output is correct |
9 |
Correct |
12 ms |
1808 KB |
Output is correct |
10 |
Correct |
12 ms |
1876 KB |
Output is correct |
11 |
Correct |
12 ms |
1872 KB |
Output is correct |
12 |
Correct |
12 ms |
1816 KB |
Output is correct |
13 |
Correct |
12 ms |
1892 KB |
Output is correct |
14 |
Correct |
12 ms |
1908 KB |
Output is correct |
15 |
Correct |
12 ms |
1836 KB |
Output is correct |
16 |
Correct |
13 ms |
1792 KB |
Output is correct |
17 |
Correct |
12 ms |
1876 KB |
Output is correct |
18 |
Correct |
12 ms |
1876 KB |
Output is correct |
19 |
Correct |
12 ms |
1856 KB |
Output is correct |
20 |
Correct |
12 ms |
1864 KB |
Output is correct |
21 |
Correct |
12 ms |
1860 KB |
Output is correct |
22 |
Correct |
12 ms |
1800 KB |
Output is correct |
23 |
Correct |
13 ms |
1876 KB |
Output is correct |
24 |
Correct |
12 ms |
1876 KB |
Output is correct |
25 |
Correct |
13 ms |
1824 KB |
Output is correct |
26 |
Correct |
12 ms |
1876 KB |
Output is correct |
27 |
Correct |
12 ms |
1784 KB |
Output is correct |
28 |
Correct |
12 ms |
1876 KB |
Output is correct |
29 |
Correct |
12 ms |
1792 KB |
Output is correct |
30 |
Correct |
12 ms |
1876 KB |
Output is correct |
31 |
Incorrect |
12 ms |
1864 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |