O(n²)
int c[N][N];//存储c(n,m)%P的组合数
for (int i = 0; i < N; i++)
{
for (int j = 0; j <= i; j++)
{
if (!j)
{
c[i][j] = 1;
}
else
{
c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % P;
}
}
}
O(nlogn)
int fact[N], infact[N];//fact存储阶乘取模余数,infact存储阶乘取模逆元
int qmi(int m, int k, int p) //求m^k mod p,注意数据范围
{
int res = 1;
while (k)
{
if (k & 1)
{
res = (ll)res * m % p;
}
m = (ll)m * m % p;
k >>= 1;
}
return res;
}
int C(int a, int b, int p) //C(a,b)%P的值
{
return (ll)fact[a] * infact[b] % p * infact[a - b] % p;
}
fact[0] = infact[0] = 1;
for (int i = 1; i < N; i++) //预处理
{
fact[i] = (ll)fact[i - 1] * i % P;
infact[i] = (ll)infact[i - 1] * qmi(i, P - 2, P) % P;
}
O(plogn)
int qmi(int m, int k, int p) //求m^k mod p,注意数据范围
{
int res = 1;
while (k)
{
if (k & 1)
{
res = (ll)res * m % p;
}
m = (ll)m * m % p;
k >>= 1;
}
return res;
}
int C(int a, int b, int p)
{
if (a < b)
{
return 0;
}
int res = 1, inv = 1;
for (int i = 1, j = a; i <= b; i++, j--)
{
res = (ll)res * j % p;
inv = (ll)inv * i % p;
}
res = (ll)res * qmi(inv, p - 2, p) % p;
return res;
}
int lucas(ll a, ll b, int p)//求c(a,b)%p,p为质数
{
if (a < p && b < p)
{
return C(a, b, p);
}
return (ll)C(a % p, b % p, p) * lucas(a / p, b / p, p) % p;
}
O(n)求C(a,b)真实值
int primes[N], cnt;
int sum[N];
bool s[N];
void get_primes(int n)
{
for (int i = 2; i <= n; i++)
{
if (!s[i])
{
primes[cnt++] = i;
}
for (int j = 0; primes[j] <= n / i; j++)
{
s[primes[j] * i] = true;
if (i % primes[j] == 0)
{
break;
}
}
}
}
int get(int n, int p)
{
int res = 0;
while (n)
{
res += n / p;
n /= p;
}
return res;
}
vector<int> mul(vector<int> a, int b)//高精乘
{
vector<int> c;
int t = 0;
for (int i = 0; i < a.size(); i++)
{
t += a[i] * b;
c.push_back(t % 10);
t /= 10;
}
while (t)
{
c.push_back(t % 10);
t /= 10;
}
return c;
}
int main()
{
std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int a, b;
cin >> a >> b;
get_primes(a);
for (int i = 0; i < cnt; i++)
{
int p = primes[i];
sum[i] = get(a, p) - get(a - b, p) - get(b, p);
}
vector<int> res;
res.push_back(1);
for (int i = 0; i < cnt; i++)
{
for (int j = 0; j < sum[i]; j++)
{
res = mul(res, primes[i]);
}
}
for (int i = res.size() - 1; i >= 0; i--)
{
cout << res[i];
}
return 0;
}