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 chenxuan123456789 at 2012-07-28 19:36:44 on Problem 3006
#include <stdio.h>
#include <math.h>
int judge(__int64 n)
{
	__int64 i=2;
	if(n==1)
	return 0;
	if(n==2)
	return 1;
	for(i=2;i<=sqrt(n);i++)
	if(n%i==0)
	return 0;
	return 1;
}
int main()
{
	__int64 a,d,n,count;
	while(scanf("%I64d %I64d %I64d",&a,&d,&n)!=EOF)
	{
		 
		if(a==0&&d==0&&n==0)
	    break;
	    count=0;
	    while(1)
	    {
	    	if(judge(a))
	    	count++;
	    	if(count==n)
	    	{
	    		printf("%I64d\n",a);
	    		break;
	    	}
	    	else
	    	a+=d;
	    }
	}
	return 1;
}
	  

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