AcWing 211. Calculation factor

Insert picture description here

code show as below:

#include <iostream>
using namespace std;
const int N = 1010;
const int MOD = 10007; 
int c[N][N];
typedef long long LL;
int power(int a,int b)
{
    
    
    int res = 1;
    a = a%MOD;
    while(b--) res = res*a%MOD;
    return res;
}

int main()
{
    
    
    int a,b,k,n,m;
    cin>>a>>b>>k>>n>>m;
    for (int i = 0;i<=k;i++)
        for (int j = 0;j<=i;j++)
        {
    
    
            if (!j) c[i][j] = 1;
            else
            {
    
    
                c[i][j] = (c[i-1][j]+c[i-1][j-1])%MOD;
            }
        }
        
    cout<<c[k][n]*power(a,n)%MOD*power(b,m)%MOD<<endl;
    return 0;
}

Guess you like

Origin blog.csdn.net/m0_51955470/article/details/114175889