15 solutions

  • 0
    @ 2022-1-18 14:12:42

    #打卡

    #include <bits/stdc++.h>
    typedef long long ll;
    using namespace std;
    ll isprime(ll x)
    {
    	int ret=1;
    	if(x==2) ret=1;
    	if(x==1||x==0) ret=0;
    	for(ll i=2;i<=sqrt(x);i++)
    	{
    		if(x%i==0)
    			ret=0;
    	}
    	return ret;
    }
    int main()
    {	ll n;
    	cin>>n;
    	if(isprime(n)) 
    	{
    		cout<<n<<endl;
    		return 0;
    	}
    	ll ans=1;
    	for(ll i=2;i*i<=n;i++)
    	{
    		ll cnt=0;
    		while(n%i==0)
    		{
    			cnt++;
    			n/=i;
    		}
    		if(cnt&1) ans*=i;
    	}
    	ans*=n;
    	cout<<ans<<endl;
    	return 0;
    }
    

    Information

    ID
    189
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    484
    Accepted
    89
    Uploaded By