Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
28496 hi_hi 【J】T3 C++ 通过 100 196 MS 10744 KB 811 2024-04-14 20:03:40

Tests(10/10):


#include<bits/stdc++.h> using namespace std; map<long long,long long> cnt; long long ans,t,n,top,p[100005],a[100005]; int sss(long long x){ for(int i=2;i<x;i++){ if(x%i==0)return 0; } return 1; } long long r(long long x){ for(int i=1;i<=top;i++){ while(x%p[i]==0)x/=p[i]; if(p[i]>x)break; } return x; } int main(){ for(int i=2;i<=1300;i++){ if(sss(i))p[++top]=(long long)i*i*i; } // for(int i=1;i<=top;i++){ // printf("%lld ",p[i]); // } scanf("%lld",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); a[i]=r(a[i]); cnt[a[i]]++; } for (auto& i:cnt){ if(i.first==1){ ans++; continue; } else{ long long k=r((i.first)*(i.first)); ans+=max(i.second,cnt[k]); cnt[k]=0; i.second=0; } } printf("%lld",ans); return 0; }


测评信息: