解题思路
比较简单的题,用二项式定理即可。
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> using namespace std; const int MAXN = 1005; const int mod = 10007; typedef long long LL; inline int rd(){ int x=0,f=1;char ch=getchar(); while(!isdigit(ch)) {f=ch=='-'?0:1;ch=getchar();} while(isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();} return f?x:-x; } int a,b,k,n,m; LL C[MAXN][MAXN]; int fast_pow(int x,int y){ int ret=1; for(;y;y>>=1){ if(y&1) ret=(LL)ret*x%mod; x=(LL)x*x%mod; } return ret; } int main(){ a=rd(),b=rd(),k=rd(),n=rd(),m=rd(); for(int i=1;i<=k+1;i++){ C[i][0]=1; for(int j=1;j<=i;j++) C[i][j]=C[i-1][j]+C[i-1][j-1],C[i][j]%=mod; } printf("%lld",(LL)fast_pow(a,n)*fast_pow(b,m)%mod*C[k+1][n]%mod); return 0; }