Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01 lives exactly x days. Now RC-01 produces exactly p new deadly Bacteria where x = bp (where b, p are integers). More generally, x is a perfect pth power. Given the lifetime x of a mother RC-01 you are to determine the maximum number of new RC-01 which can be produced by the mother RC-01.
Input
Input starts with an integer T (≤ 50), denoting the number of test cases.
Each case starts with a line containing an integer x. You can assume that x will have magnitude at least 2 and be within the range of a 32 bit signed integer.
Output
For each case, print the case number and the largest integer p such that x is a perfect pth power.
Sample Input
3
17
1073741824
25
Sample Output
Case 1: 1
Case 2: 30
Case 3: 2
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
const int N=1e7+5;
const int NN=1e6;
int prime[NN];
bool vis[N];
int cnt=0;
void is_prime()
{
cnt=0;
memset(vis,0,sizeof(vis));
for(int i=2;i<N;i++)
{
if(!vis[i])
{
prime[cnt++]=i;
for(int j=i+i;j<N;j+=i)
{
vis[j]=1;
}
}
}
}
ll gcd(ll a, ll b)
{
return a % b == 0 ? b : gcd(b, a % b);
}
int main()
{
ll t, p = 0;
ll n;
is_prime();
cin>>t;
while(t--)
{
bool judge=false;
p++;
cin>>n;
if(n<0){
n=-n;
judge=true;
}
ll x, ans = 0;
for(ll i = 0 ; i < cnt && prime[i] * prime[i] <= n ; i++)
{
if(n % prime[i] == 0)
{
x = 0;
while(n % prime[i] == 0)
{
x++;
n /= prime[i];
}
if(ans == 0)
ans = x;
else
ans = gcd(ans, x);
}
}
if(n > 1)
ans = 1;
if(judge){
while(ans%2==0){
ans/=2;
}
}
cout<<"Case "<<p<<": "<<ans<<"\n";
}
return 0;
}