| ||||||||||
| 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 | |||||||||
代码!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator