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

为啥都过了还是WA啊??!!哭死了 ```贡献了N次

Posted by s2009zy at 2009-12-02 16:47:38 on Problem 3006
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
	int a,b,n;
	int i,j,k;
    double sum,zem;
	while(cin>>a>>b>>n)
	{
		if(a==0&&b==0&&n==0)
			break;
		k=0;
		sum=a;
		zem=0;
		for(i=1;;i++)
		{
		
			for(j=2;j<=sqrt(sum);j++)
			{	
				if(int(sum)%j==0)
					break;
			}
			if(j>sqrt(sum))
			{
				k++;
				zem=sum;			
			}
			sum=sum+b;		
			if(k==n)
			{
				break;
			}
		}
		if(zem==1)
		{
			cout<<'2'<<endl;
		}
		else
		{
			cout<<zem<<endl;
		}
	}
	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