zoukankan      html  css  js  c++  java
  • cf1033D

    每一个数都是 p*q p^2 p^3 p^4 的形式,分类讨论即可

    #include<bits/stdc++.h>
    #define forn(i, n) for (int i = 0 ; i < int(n) ; i++)
    #define fore(i, s, t) for (int i = s ; i < (int)t ; i++)
    #define fi first
    #define se second
    #define all(x) x.begin(),x.end()
    #define pf2(x,y) printf("%d %d
    ",x,y)
    #define pf(x) printf("%d
    ",x)
    #define each(x) for(auto it:x)  cout<<it<<endl;
    #define pii pair<int,int>
    #define sc(x) scanf("%d",&x)
    using namespace std;
    typedef long long ll;
    const int maxn=2e5+5;
    const int maxm=2e5+5;
    const int inf=1e9;
    const ll mod=998244353;
    ll a[maxn],n;
    
    
    long long my_sqrt(long long x) {
    	long long l=1,r=2e9;
    	while(l<r){
    		long long mid=(l+r+1)>>1;
    		if(mid*mid<=x) l=mid;
    		else r=mid-1;
    	}
    	return l;
    }
    long long my_crt(long long x) {
    	assert(x > 0);
    	long long y = (long long) (powl((long double) x, 1.0 / 3.0) + 0.5);
    	while (y * y * y<x) y++;
    	while (y * y * y>x) y--;
    	if (y * y * y == x) {
    		return y;
    	}
    	return -1;
    }
    int main() {
    	cin>>n;
    	for(int i=0;i<n;i++)
    		cin>>a[i];
    	map<ll,vector<pair<ll,ll>>> ls;
    	ll ans=1;
    	map<ll,ll> eq;
    	for(int i=0;i<n;i++){
    		ll t=my_sqrt(a[i]);
    		if(t*t==a[i]) {
    			ll k=my_sqrt(t);
    			if(k*k*k*k==a[i]) ls[i].push_back({k,4});
    			else ls[i].push_back({t,2}); 
    		}
    		else {
    			t=my_crt(a[i]);
    			if(t*t*t==a[i]) {
    				ls[i].push_back({t,3});
    			}
    			else {
    				bool flag=0;
    				for(int j=0;j<n;j++){
    					if(j==i || a[i] == a[j])  continue;
    					ll g=__gcd(a[i],a[j]);
    					if(g!=1) {
    						ls[i].push_back({g,1});
    						ls[i].push_back({a[i]/g,1});
    						flag=1;break;
    					}
    				}
    				if(!flag) {
    					eq[a[i]]++;
    				}
    			}
    			
    		}
    	}
    	for(auto i:eq)
    		if(i.se==1) ans=ans*4%mod;
    		else ans=ans*(i.se+1)%mod*(i.se+1)%mod;
    	map<ll,ll> ct;
    	for(auto i:ls)
    		for(auto j:i.se)
    			ct[j.fi]+=j.se;
    	for(auto i:ct)
    		ans=ans*(i.se+1)%mod;
    	cout<<ans<<endl;
    }
    

      

  • 相关阅读:
    数据库Connection.OPEN()异常情况下 耗时很久才回应
    System.Threading.Tasks.TaskExceptionHolder.Finalize() 系统错误c#
    WCF双向通讯netTCP
    并行LINQ PLinq
    winform调用http
    kindle电子书的资源网站
    vscode设置中文语言
    Python拼接路径
    Python查看已安装模块
    Python查看模块版本
  • 原文地址:https://www.cnblogs.com/033000-/p/12395375.html
Copyright © 2011-2022 走看看