HRBUST 1328 相等的最小公倍数

http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1328

判断n因式分解后是否是a^b的形式,是则输出NO,反之YES

View Code
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int jj(int n)
{
int i,f1=0,f2=0,t;
t=n;
for(i=2;i<t;i++)
{
if(!f1)
{
if(n%i==0)
{
f1=1;
while(n%i==0)
n/=i;
}
}
else
{
if(n%i==0)
{
f2=1;
break;
}
}
}
if(f2)
return 1;
return 0;
}
int main()
{
int n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(jj(n))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
原文地址:https://www.cnblogs.com/xiaohongmao/p/2433980.html