You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
989 B
C++

#include <cstdio>
#include <cstring>
using namespace std;
typedef long long i64;
const int N=1e7+5;
bool notPrime[N];
int prime[N/10];
void genprime()
{
memset(notPrime,0,sizeof(notPrime));
memset(prime,0x3f3f3f3f,sizeof(prime));
int cnt=0;
notPrime[0]=notPrime[1]=true;
for(int i=2,j; i*i<N; i++)
if(!notPrime[i])
for(prime[cnt++]=i, j=i*i; j<N; j+=i)
notPrime[j]=true;
}
int main()
{
genprime();
int T;
scanf("%d",&T);
for(int t=1; T<=T; t++)
{
i64 n,ans=1;
scanf("%lld",&n);
for(int i=0; 1ll*prime[i]*prime[i]<=n; i++)
{
if(n%prime[i]==0)
{
int cnt=0;
while(n%prime[i]==0)
n/=prime[i],cnt++;
ans*=(cnt<<1|1);
}
}
if(n>1)
ans*=3;
printf("Case %d: %lld\n",t,(ans+1)>>1);
}
return 0;
}