题目:
题解:
比较简单的数论题,用杨辉三角求解,记住aa[i]/bb[i]表达的是x/y的i次方
代码:
#include <cstdio>
#include <cstring>
#define Mod 10007
using namespace std;
int f[1005][1005],aa[1005],bb[1005];
int main()
{
int a,b,k,n,m,i,j;
scanf("%d%d%d%d%d",&a,&b,&k,&n,&m);
a%=Mod; b%=Mod;
for (i=1;i<=k;i++) aa[i]=bb[i]=1;
aa[0]=1;
for (i=1;i<=n;i++)
aa[i]=a*aa[i-1]%Mod;
bb[0]=1;
for (i=1;i<=m;i++)
bb[i]=b*bb[i-1]%Mod;
for (i=1;i<=k;i++)
for (j=1;j<=i+1;j++)
if (j==1||j==i+1) f[i][j]=1;
else f[i][j]=(f[i-1][j-1]+f[i-1][j])%Mod;
printf("%d",(f[k][k-n+1]*aa[n])%Mod*bb[m]%Mod);
}