HUST Online Judge WebBoard
Problem 4039 >> 为什么时间超限
201803020136 @ 2019-04-16 21:00:31
[ Quote ] [ Edit ] [ Delete ] 1#

#include<stdio.h>
int main()
{
long int isprime(long int num);
long int i,j,n;
scanf("%ld",&n);
for(i=2;i<n/2;i++)
{
j=n/i;
if(n==i*j&&isprime(i)&&isprime(j))
{
printf("%ld\n",i>j?i:j);
break;
}
}
}

long int isprime(long int num)
{
long int i;
for(i=2; i<num/2; i++)
if(num%i==0)
return 0;
return 1;
}
201803120130 @ 2019-04-18 20:43:44
[ Quote ] [ Edit ] [ Delete ] 2#
算法不够快