OJ-Problems-Source/HDOJ/5430_autoAC.cpp
KiritoTRw b39288d6ef Powered By HC TECH : AutoACer Engine
5400-5504(END by now)
2016-09-13 04:55:33 +08:00

32 lines
492 B
C++

#include<stdio.h>
#define LL long long
LL fun(LL m)
{
LL res=m;
for(LL i=2;i*i<=m;i++)
{
if(m%i==0)
{
res=(res*(i-1))/i;
while(m%i==0)
{
m/=i;
}
}
}
if(m>1) res=(res*(m-1))/m;
return res;
}
int main()
{
LL n;
int T;
scanf ("%d",&T);
while(T--)
{
scanf("%lld",&n);
printf("%lld\n",fun(n+1));
}
return 0;
}