原题目:
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 = b的p次方 (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
题意:求给出x的b的最大p次方(b,p未知整数)
输入:
第一行一个整数T
接下来T行,每行一个x。
思路:
求x的唯一质数因子,因为是求质数因子,所以先用素数筛,将质数筛选出来,然后对筛选出来的质因子进行求次方数。
最后,求x各质因子的最大公因数(gcd)即可。
AC代码:
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N = 100010;
typedef long long ll;
int prime[N],ans=0;