【洛谷P1313 计算系数】

时间:2021-10-04 21:59:15

题目连接

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cctype>
#define ll long long
#define gc getchar
#define maxn 1005
#define mo 10007
using namespace std;
inline ll read()
{
ll a=;int f=;char p=gc();
while(!isdigit(p)){f|=p=='-';p=gc();}
while(isdigit(p)){a=(a<<)+(a<<)+(p^);p=gc();}
return f?-a:a;
}
int n,m,k,a,b,f[maxn][maxn];
int pow(int a,int k)
{
int ans=;
while(k)
{
if(k&)ans=ans*a%mo;
a=a*a%mo;k>>=;
}
return ans;
} int main()
{
f[][]=;
a=read()%mo;b=read()%mo;k=read();n=read();m=read();
for(int i=;i<=k;++i)
{
f[i][]=;
for(int j=;j<=i;++j)
f[i][j]=(f[i-][j-]+f[i-][j])%mo;
}
printf("%d\n",f[k][n]*pow(a,n)%mo*pow(b,m)%mo);
return ;
}

同样by子谦。(是HMY,不是钟子谦奆佬QWQ)大佬的面对面讲解

原谅我大括号换行。。。