Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么这样就错???#include <iostream> using namespace std; long long temp; bool prime(long long n) { long long i; for( i=3;i*i<=n;i+=2) { if(n%i==0) { temp=i; break; } } if(i*i<=n)return 0; return 1; } int main() { int t; scanf("%d",&t); while(t--) { long long n; scanf("%I64d",&n); if(n%2==0) printf("2\n"); else { temp=0; bool sum=prime(n); if(sum) printf("Prime\n"); else printf("%I64d\n",temp); } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator