1 条题解

  • 0
    @ 2021-6-15 1:40:19

    C++ :

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    
    const int N=1010,MOD=10007;
    int C[N][N],a,b,k,n,m;
    
    int main() {
    	scanf("%d%d%d%d%d",&a,&b,&k,&n,&m);
    	a%=MOD; b%=MOD;
    	C[0][0]=1;
    	for(int i=1;i<=k;i++) {
    		C[i][0]=C[i-1][0]*b%MOD;
    		for(int j=1;j<=min(i,n);j++)
    			C[i][j]=(C[i-1][j-1]*a%MOD+C[i-1][j]*b%MOD)%MOD;
    	}
    	printf("%d\n",C[k][n]);
    	return 0;
    }
    

    Pascal :

    program factor;
    var
      f:array[1..1005,0..1005]of longint;
      ans,a,b,k,n,m,i,j:longint;
    begin
      readln(a,b,k,n,m);
      a:=a mod 10007;
      b:=b mod 10007;
      f[1,1]:=1;
      for i:=2 to k+1 do
        for j:=1 to i do
          f[i,j]:=(f[i-1,j]+f[i-1,j-1])mod 10007;
      ans:=f[k+1,m+1];
      for i:=1 to n do
        ans:=(ans*a)mod 10007;
      for i:=1 to m do
        ans:=(ans*b)mod 10007;
      writeln(ans);
    end.
    
    
    • 1

    信息

    ID
    291
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者