AcWing 3491. 完全平方数
原题链接
简单
作者:
最后五分钟
,
2024-04-05 02:40:10
,
所有人可见
,
阅读 4
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define de(x) cout<<#x<<" = "<<x<<" "
#define deg(x) cout<<#x<<" = "<<x<<endl
using namespace std;
const int N=10010,M=10010;
typedef pair<int,int> PII;
vector<PII> fa;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=2;i<=n/i;i++)
{
int t=0;
while(n%i==0)t++,n/=i;
if(t)fa.push_back({i,t});
}
if(n>1)fa.push_back({n,1});
int res=1;
for(int i=0;i<fa.size();i++)
{
if(fa[i].y&1)res*=fa[i].x;
}
cout<<res<<endl;
return 0;
}