http://lightoj.com/volume_showproblem.php?problem=1220
Mysterious Bacteria
Time Limit:500MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Description
Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01 lives exactlyx days. Now RC-01 produces exactlyp new deadly Bacteria wherex = bp (whereb, p are integers). More generally,x is a perfectpth power. Given the lifetimex 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 integerT (≤ 50), denoting the number of test cases.
Each case starts with a line containing an integerx. You can assume thatx 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 integerp such thatx is a perfectpth power.
Sample Input
3
17
1073741824
25
Sample Output
Case 1: 1
Case 2: 30
Case 3: 2
题意:
给一个整数x,求满足x = bp(均为整数)条件的最大p值
则求出x=a1p1 *a2p2*a3p3……anpn
其中a1……an均为素数
然后求ans = gcd(p1,p2,……,pn);
有一个坑,就是n可能为负数,这时,ans必须为奇数……
Code
#include
#include
#include
#include
#include
#include
#include
#include
#include