Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
28482 | 22级赵奕绚 | 【J】T3 | C++ | 解答错误 | 50 | 41 MS | 3504 KB | 1010 | 2024-04-14 19:32:51 |
#include<bits/stdc++.h> using namespace std; int n,a[100010]; long long cnt[1500],num,f,ans; map<long long,int>s; int main(){ cin >> n; for(int i=1;i<=n;i++){ cin >> a[i]; } for(int i=2;(long long)i*i*i<=1400;i++){ bool flag=true; for(int j=2;j*j<=i;j++){ if(i%j==0){ flag=false; break; } } if(flag==true) cnt[num++]=i; } // for(int i=0;i<num;i++)cout<<cnt[i]<<" "; for(int i=1;i<=n;i++){ for(int j=0;j<num;j++){ while(a[i]%(cnt[j]*cnt[j]*cnt[j])==0) a[i]/=(cnt[j]*cnt[j]*cnt[j]); } } for(int i=1;i<=n;i++){ s[a[i]]++; } // for(auto &it:s){ // cout << it.first << " " << it.second << endl; // } for(auto &it:s){ if(it.first==1){ ans++; continue; } f=it.first*it.first; for(int j=0;j<num;j++){ while(f%(cnt[j]*cnt[j]*cnt[j])==0) f/=(cnt[j]*cnt[j]*cnt[j]); } if(s.count(f)){ ans+=max(it.second,s[f]); it.second=s[f]=0; } else ans+=it.second; } cout << ans << endl; return 0; }