球与盒子 2
C++// PikachuQAQ 2024/07/24
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1e4 + 2, mod = 1e9 + 7;
int n, k, fact[kMaxN], ifact[kMaxN], inv[kMaxN];
int pow(int a, int b, int p = mod) {
int res = 1;
for (; b; b >>= 1, a = 1ll * a * a % p) {
if (b & 1) {
res = 1ll * res * a % p;
}
}
return res % p;
}
void init() {
inv[1] = fact[0] = fact[1] = 1;
ifact[0] = ifact[1] = 1;
for (int i = 2; i < kMaxN; i++) {
fact[i] = 1ll * i * fact[i - 1] % mod;
inv[i] = pow(i, mod - 2);
ifact[i] = 1ll * ifact[i - 1] * inv[i] % mod;
}
}
int A(int n, int k) {
return 1ll * fact[n] * ifact[n - k] % mod;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
init();
cin >> n >> k;
if (n > k) {
cout << "0\n";
return 0;
}
cout << A(k, n) << '\n';
return 0;
}