参考代码

austin2010 2023-01-15 15:28:43 14 返回题目

这题用二项式定理解

需要用到组合数

答案其实是C(m+1,k+1)

要用杨辉三角求答案

代码区------------------------

#include<bits/stdc++.h>

#define p 10007

using namespace std;

long long x[1010][1010];

int main()

{

long long a,b,k,n,m;

cin>>a>>b>>k>>n>>m;

x[1][1]=1;

for(int i=2;i<=k+1;i++) for(int j=1;j<=i;j++)

x[i][j]=(x[i-1][j-1]*b+x[i-1][j]*a)%p;

cout<<x[k+1][m+1];

return 0;

}

100分 AC完毕

{{ vote && vote.total.up }}