| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
本机测试数据正确,OJ却判定为Wrong Answer# 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator