zoukankan      html  css  js  c++  java
  • [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
    
  • 相关阅读:
    python 获取文件大小,创建时间和访问时间
    url中的20%、22%、26%、7B%、%7D、28%、29% 代表真实的字符(转发)
    python3 采集需要登录的网页数据
    python3 模拟鼠标中轴滚动
    python3 爬虫小技巧,
    马拉松中级训练计划
    python 使用夜神模拟器
    Python3+mitmproxy安装使用教程(Windows)(转载)
    adb server version (31) doesn't match this client (41); killing...
    appium+python环境搭建
  • 原文地址:https://www.cnblogs.com/akoasm/p/9577563.html
Copyright © 2011-2022 走看看