#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL k,p,n,ans=1,m;
LL qr(LL x,LL y)
{
LL ans=1;
while (y)
{
if (y&1) ans*=x;
x*=x;
y>>=1;
}
return ans;
}
main()
{
scanf("%lld",&n);
m=sqrt(n);
for (LL i=2;i<=m;i++)
if (n%i==0)
{
p=i;
k=0;
while (n%i==0)
{
n/=i;
k++;
}
ans*=((k+1)*qr(p,k)-k*qr(p,k-1));
}
if (n!=1) ans*=(2*n-1);//这一步可以自己思考一下
printf("%lld",ans);
}
【BZOJ2705】Longge的问题,数论练习
最新推荐文章于 2023-08-22 15:26:40 发布