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

本机测试数据正确,OJ却判定为Wrong Answer

Posted by camus_ym at 2014-09-08 19:37:23 on Problem 3006 and last updated at 2014-09-08 19:37:49
# include <stdio.h>
# include <math.h>

int isPrime(int n)
{
	int i;
	for (i=2;i*i<=n;i++)
		if (n%i==0)return 0;
	return 1;
}

int main()
{
	int a,d,n;
	while (3==scanf("%d%d%d",&a,&d,&n)&&a!=0&&d!=0&&n!=0)
	{
		if (a==1 && d==1 && n==1)
		{
			printf("%d\n",a+d*n);
		}else	{
			int m,cnt = 0;
			for (m=a;cnt<n;m+=d)
			{
				if (isPrime(m))++cnt;
			}
			printf("%d\n",m-d);
		}		
	}
	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