题意:
给出一个数x 求 x = bp 的p的最大值
解析:
算术基本定理 分解质因数
任何一个数x都可以表示为 x == p1a1 * p2a2 * ````` * pnan
即 bp == p1a1 * p2a2 * ````` * pnan == (p1b1 * p2b2 * `````` * pnbn)p
所以 pmax == gcd(a1,a2,·····,an);
如果x是一个负数 则p只能为奇数
先把x换成正数求出最大p之后 如果x 为负 则不断除2 直至p为奇数
代码如下:
#include #include #include #include #include