求调
查看原帖
求调
553501
可爱的小棉羊楼主2024/8/20 15:28
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005];
bool f=0;
map<long long,int>mp;
map<long long,long long>mp2;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
//	freopen("lovely.in","r",stdin);
//	freopen("lovely.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		for(long long j=2;j*j*j<=a[i];j++){
			while(a[i]%(j*j*j)==0)a[i]/=j*j*j;
		}
		if(a[i]==1){
			f=1;
			i--;
			n--;
			continue;	
		}
		mp[a[i]]++;
		__int128 b=1;
		long long tmp=a[i];
		for(long long j=2;j*j*j<=a[i];j++){
			if(tmp%(j*j)==0){
				tmp/=j*j;
				b*=j;
			}else if(tmp%j==0){
				tmp/=j;
				b*=j*j;
			}
		}
		if(tmp>1){
			long long s=(long long)(sqrt(tmp)+0.5);
			if(s*s==tmp){
				b*=s;
			}else{
				
				b*=(__int128)tmp*tmp;
			}
		}
		if(b<=1e10)mp2[a[i]]=b;
	}
	int ans1=0,ans2=0;
	for(auto u:mp){
//		cout<<u.first<<" "<<u.second<<"\n";
		int a=u.first,cnt=u.second;
		if(u.second==0)continue;
		int b=mp2[a],cnt2=mp[b];
//		cout<<b<<" "<<cnt2<<"\n";
		if(cnt2==0)ans2+=cnt;
		else{
			ans1+=max(cnt2,cnt);
		}
		mp[b]=0;
		mp[a]=0;
	}
	cout<<ans1+ans2+f;
	return 0;
}//2*2*5=20
//2*5*5=50

/*12
9 8 7 6 5 4 3 2  4 8 9 9*/

WA on#13

2024/8/20 15:28
加载中...