NC16596 [NOIP2011]计算系数
https://ac.nowcoder.com/acm/problem/16596
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 10007;
int frac[1002];
void ini()
{
frac[0] = frac[1] = 1;
for(int i=2;i<=1001;++i)
frac[i] = frac[i-1] * i % mod;
}
int pf(int x,int b)
{
int res = 1;
while(b>0)
{
if(b&1) res = res * x % mod;
x = x * x % mod;
b >>= 1;
}
return res;
}
int C(int n,int k)
{
return frac[n] * pf(frac[k], mod-2) % mod * pf(frac[n-k], mod-2) % mod;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int a,b,n,m,k;
cin >> a >> b >> k >> n >> m;
ini();
//cout << C(k, m) << " " << pf(a, n) << " " << pf(b, m) << endl;
cout << C(k, m) * pf(a, n) % mod * pf(b, m) % mod << endl;
return 0;
}