Chri_K

构造(排列组合 插板法)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1000000;
const int mod = 1e9+7;
ll fac[maxn];
ll x = 1;
ll qpow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll C(ll a, ll b) {
    if (a == 0 || a < b) {
        return 0;
    }
    if (b == 0) {
        return 1;
    }
    return fac[a] * qpow(fac[b], mod - 2) % mod * qpow(fac[a - b], mod - 2) % mod;
}
int main()
{
    freopen("structure.in","r",stdin);
    freopen("structure.out","w",stdout);
    fac[0] = 1;
    for (int i = 1; i < maxn; ++i) {
        fac[i] = 1ll * i * fac[i - 1] % mod;
    }
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 2; i <= m; ++i) {
        if (m % i == 0) {
            int cnt = 0;
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            if (cnt >= 2) {
                x *= qpow(i, cnt / 2);
            }
        }
    }
//    printf("%lld\n", x);
    printf("%lld\n", C(x + n - 1, n-1));
}

 

posted on 2020-10-29 14:50  Chri_K  阅读(152)  评论(0编辑  收藏  举报