_PLGW_ @ 2024-10-31 22:11:20
int J(int a)
{
int j = 0;
for (int i = 2; i < a - 1; i++)
{
if (a % i == 0)
{
return 0;
break;
}
else
{
j++;
}
}
if (j == a - 2)
{
return 1;
}
}
#include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 2; i < n - 2; i++)
{
if (n % i == 0)
{
if (J(i) && J(n / i))
{
(i >= (n / i)) ? (printf("%d", i)) : (printf("%d", (n / i)));
break;
}
}
}
return 0;
}
by sunpeilun @ 2024-10-31 22:16:03
判断质数不用那么麻烦
bool isM(int n){
for(int i=2;i*i<=n;i++){
if(n%i==0) return 0;
}
return 1;
}
by _PLGW_ @ 2024-10-31 22:33:00
@sunpeilun 牛啊!可以了,谢谢!学到了!