注意:
(1)特殊情况1
(2)经量减少循环次数,避免超时
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int main()
{
int n,i,j,a,s=0;
scanf(“%d”,&n);
for(i=1;i<=n;i)
{
scanf(“%d\n”,&a);
if(a==1)
printf(“1 is prime”);
else
{
s=0;
for(j=2;j<=sqrt(a);j)
{
if(a%j==0)
s=s+j;
}
if(s!=0)
printf(“%d is not prime\n”,a);
else
printf(“%d is prime\n”,a);
}
}
return 0;
}