Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
28492 | hi_hi | 【J】T3 | C++ | 解答错误 | 50 | 200 MS | 10752 KB | 838 | 2024-04-14 19:53:09 |
#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*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<=1260;i++){ if(sss(i))p[++top]=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)); if(cnt.count(k)) { ans+=i.second; } else ans+=max(i.second,cnt[k]); cnt[k]=0; } } printf("%lld",ans); return 0; }