ABCd求调
  • 板块学术版
  • 楼主Luka__Modric
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/2/24 23:30
  • 上次更新2024/2/25 12:25:48
查看原帖
ABCd求调
839893
Luka__Modric楼主2024/2/24 23:30
#include <iostream>
using namespace std;
#define int long long
int n,a[200010],t[200010],ans;
int fen(int x){
	int tmp=1;
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			int ci=0;
			while(x%i==0)
				x/=i,ci++;
			if(ci%2)
				tmp*=i;
		}
	}
	tmp*=x;
	return tmp;
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==0)
			continue;
		a[i]=fen(a[i]);
	}
	for(int i=1;i<=n;i++)
		t[a[i]]++,ans+=t[a[i]]*(a[i]!=0)+t[0]-1;
	cout<<ans;
    return 0;
}


/*
       ┏┓   ┏┓
     ┏┛┻━━━┛┻┓
     ┃       ┃
     ┃   ━   ┃
     ┃ ┳┛ ┗┳ ┃
     ┃       ┃
     ┃   ┻   ┃
     ┃       ┃
     ┗━┓   ┏━┛Codes are far away from bugs with the animal protecting
         ┃   ┃    神兽保佑,代码无bug
         ┃   ┃
         ┃   ┗━━━┓
         ┃      ┣┓
         ┃     ┏┛
         ┗┓┓┏━┳┓┏┛
           ┃┫┫ ┃┫┫
           ┗┻┛ ┗┻┛     ○| ̄|_

*/

2024/2/24 23:30
加载中...