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 vince4053040 at 2009-11-26 21:19:45 on Problem 3006
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,d,n;
	int p,x,m,i;
	double prime[212];
	while(cin>>a>>d>>n)
	{
		if((a==0)&&(d==0)&&(n==0))
			break;
		x=0;
		if((a==1)&&(d==1)&&(n==1))
			cout<<2<<endl;
		else{
			for(m=1;;m++)
			{
				p=0;
				for(i=2;i<=sqrt(double(a+(m-1)*d));i++)
				{
					if((a+(m-1)*d)%i==0)
						p=1;
				}
				if(p==0)
				{
					prime[x]=a+(m-1)*d;
					x++;
				}
				if(x==n)
					break;
			}
			cout<<prime[n-1]<<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