一道很简单的ACM 判断素数题,请各位前辈帮忙看看,感谢~!!!
Problem description Given a big integer number, you are required to find out whether it's a prime number.
Input
The first line contains the number of test cases T (1 <= T <= 20 ), then the following T lines each contains an integer number N (2 <= N < 254).
Output
For each test case, if N is a prime number, output a line containing the word "Prime", otherwise, output a line containing the smallest prime factor of N.
Sample Input
2
5
10
Sample Output
Prime
2
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int T;
long i,k,N;
bool p;
cin>>T;
while(T--)
{
cin>>N;
if(N==1) cout<<N<<endl;
else
{
p=true;
k=long(sqrt(N));
for(i=2;i<=k;i++)
if(N%i==0)
{
cout<<i<<endl;
p=false;
break;
}
if(p)
cout<<"prime"<<endl;
}
}
return 0;
}
上面是小弟的程序,一提交就 Wrong Answer,咋回事啊 请各位前辈指教,O(∩_∩)O谢谢啦~!!!