Problem: 3006 User: angrad
Memory: 136K Time: 250MS
Language: C Result: Accepted
-
#include <stdio.h>
-
-
int IsPrime(int a)
-
{
-
int i;
-
if (a < 2)
-
{
-
return 0;
-
}
-
for (i=2; i*i<=a; i++)
-
{
-
if (0 == a % i)
-
{
-
return 0;
-
}
-
}
-
return 1;
-
}
-
-
int main()
-
{
-
int a, d, n, i, count;
-
while(scanf("%d%d%d", &a, &d, &n) && a!=0)
-
{
-
count = 0;
-
for (i=a; count<n; i+=d)
-
{
-
if (IsPrime(i))
-
{
-
count++;
-
}
-
}
-
printf("%dn", i-d);
-
}
-
return 0;
-
}
2011-03-14 18:28 发表于百度空间,今搬至CU。
阅读(1251) | 评论(0) | 转发(0) |