I vaguely remember the relationship between the expansion and the number of combinations, but I can’t remember it until I know the binomial theorem. (x + y) n = C (n, 0) × x n × y 0 + C (n, 1) × x n − 1 × y 1 + C (n, 2) × x n − 2 × y 2…… + C (n, 0 n) x x x y n (x + y) ^ n = C (n, 0) ^ n \ \ times x times y ^ 0 + C (n, 1) \ times x ^ {n – 1} \ times y ^ 1 + C (n, 2) \ times x ^ 2} {n – \ times y^2…… + C (n, n) ^ 0 \ \ times x times y ^ n (x + y) n = C (n, 0) * y0 xn + C (n, 1) * xn – 1 * y1 + C (n, 2) * xn – 2 x y2… Plus C(n,n) times x0 times yn so if we know the binomial theorem, we’re going to have a bare problem which is C(k,n) times an times b to the m C(k,n) times an bm

AC code:

/* * @Author: hesorchen * @Date: 2020-04-14 10:33:26 * @LastEditTime: 2020-06-30 22:12:29 * @Link: https://hesorchen.github.io/ */
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI acos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 10007
#define pll pair<ll, ll>
#define lowbit(abcd) (abcd & (-abcd))
#define max(a, b) ((a > b) ? (a) : (b))
#define min(a, b) ((a < b) ? (a) : (b))

#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define FRE                              \
    {                                    \
        freopen("in.txt"."r", stdin);   \
        freopen("out.txt"."w", stdout); The \}

inline ll read(a)
{
    ll x = 0, f = 1;
    char ch = getchar(a);while (ch < '0' || ch > '9')
    {
        if (ch == The '-')
            f = - 1;
        ch = getchar(a); }while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar(a); }return x * f;
}
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
ll quick_pow(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res % mod;
}
ll jc[2500];
void init(a)
{
    jc[0] = 1;
    for (int i = 1; i < 2345; i++)
        jc[i] = jc[i - 1] * i % mod;
}
ll C(ll n, ll m)
{
    ll a = n % mod;
    ll b = m % mod;
    if (a < b)
        return 0;
    if (a && b)
        return jc[a] * quick_pow(jc[b], mod - 2) % mod * quick_pow(jc[a - b], mod - 2) % mod * C(n / mod, m / mod) % mod;
    else
        return 1;
}
int main(a)
{
    ll a, b, k, n, m;
    cin >> a >> b >> k >> n >> m;
    init(a); cout <<C(k, n) * quick_pow(a, n) * quick_pow(b, m) % mod << endl;
    return 0;
}
/ * * /
Copy the code