#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=1061109567;
int casenum,casei;
int main()
{
LL n;
while(~scanf("%lld",&n))
{
int top=sqrt(n);
LL ans=1;
for(int i=2;i<=top;i++)if(n%i==0)
{
ans*=i;
while(n%i==0)n/=i;
}
if(n)ans*=n;
printf("%lld\n",ans);
}
return 0;
}
/*
【题意】
给你一个n([1,1e12]),
我们想要找到n中的最大的一个因子,使得这个因子不是任何平方数的倍数。
【类型】
质因数分解
【分析】
不是任何平方数的倍数,等价于不是任何素数的倍数。
不是任何素数的倍数,等价于任何素数这个数都最多只含有一个。
于是我们对n做素数拆分,所有其因子素数的单次乘积结果,就是答案啦。
【时间复杂度&&优化】
O(sqrt(n))
*/
【Codeforces Round 326 (Div 2)B】【质因数分解】Duff in Love n的最大因子使其不为平方数倍数
最新推荐文章于 2024-08-28 22:49:31 发布
