Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么这样就错???

Posted by xueshanhaizi at 2008-04-26 07:52:43 on Problem 1811
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator