P1313 计算系数
https://www.luogu.com.cn/problem/P1313
题意
想法
来源于:yxc
// P1313 计算系数
// Created by majoe on 2020/6/8.
//https://www.luogu.com.cn/problem/P1313
#include <bits/stdc++.h>
using namespace std;
const int mod = 10007;
//快速幂
int qmi(int a, int k)
{
a %= mod;
int res = 1;
while (k)
{
if (k & 1) res = res * a % mod;
a = a * a % mod;
k >>= 1;
}
return res;
}
int main()
{
int a, b, k, n, m;
cin >> a >> b >> k >> n >> m;
int res = qmi(a, n) * qmi(b, m) % mod; // a^n * b^m
for (int i = 1, j = k; i <= n; i ++, j -- ) // 费马小定理
{
//将除法取余的操作,变为乘法
res = res * j % mod;
res = res * qmi(i, mod - 2) % mod;
}
cout << res << endl;
return 0;
}