[JZOJ 5813] 计算

题意:求满足题意的方案数。
思路:
显然的计数类\(dp\)
不难发现,令$f(x) = \prod_{i=1}^{2m}{x_i} \(. 在找一个\)x'\(使得\)f(x') = \prod_{i=1}^{2m}{n/x_i}$
那么,\(f(x') = n^{2m}/f(x) > n^m\)
所以说,对于\(<\)\(>\)的方案数相同,关键是求出\(=\).
\(=\)就是求有多少\(f(x) = n^m\)
将n分解质因数,考虑\(a_j\)表示\(x_j\)中包含\(p\)的指数,令\(cnt\)表示\(n\)中含有\(p\)的指数。
所以就是求\(\sum_{i=1}^{2m}a_j = cnt * m\)\(a_j > 0\)的方案数。
所以记\(dp[i][j]\)表示前\(i\)个数和为\(j\)的方案数。
所以\(dp[i][j] = \sum_{k=0}^{cnt}dp[i - 1][j - k]\)
复杂度\(O(\sqrt{n} + logn*m^2)\)
奇怪的复杂度。。。
不过...关键字坑了我一年...

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 210;
#define mod 998244353
ll tmp;
ll s;
ll n,m;
ll dp[maxn][maxn*(maxn>>3)];
inline int read (){
    int q=0,f=1;char ch = getchar();
    while(!isdigit(ch)) {
        if(ch=='-')f=-1;ch=getchar();
    }
    while(isdigit(ch)){
        q=q*10+ch-'0';ch=getchar();
    }
    return q*f;
}
inline ll pow_mod(ll x,ll y) {
    ll res = 1;
    while(y) {
        if(y & 1) res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
} 
inline void upd(ll &x,ll y) {
    x = (x + y) % mod;
}
inline void Upd(ll &x,ll y) {
    x = (x * y) % mod;
}
inline void Dp(int x) {
    int cnt = 0;
    while(tmp % x == 0) cnt ++,tmp /= x;
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1;i <= (m << 1); ++i) {
        for(int j = 0;j <= cnt * m; ++j) {
            for(int k = 0;k <= min(j,cnt); ++k) {
                upd(dp[i][j],dp[i - 1][j - k]);
            }
        }
    }
    Upd(s,dp[m << 1][cnt * m]);
}
int sum;
int main () {
    freopen("count.in","r",stdin);
    freopen("count.out","w",stdout);
    scanf("%lld %lld",&n,&m);
    int tid = sqrt(n);
    tmp = n; 
    s = 1;
    for(int i = 1;i <= tid; ++i) {
        if(n % i == 0) {
            sum += 1 + (i * i < n);
            if(i > 1 && tmp % i == 0) {
                Dp(i);
            }
        }
    }
    if(tmp > 1) {
        Dp(tmp);
    }
    sum = pow_mod(sum,m << 1);
    printf("%lld",(sum + s) * pow_mod(2,mod - 2) % mod);
    return 0;
}
//1 0 1 1 1 2 1 0 1 1 1 2

转载于:https://www.cnblogs.com/akoasm/p/9577563.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值