Chinaunix首页 | 论坛 | 博客
  • 博客访问: 473353
  • 博文数量: 59
  • 博客积分: 345
  • 博客等级: 二等列兵
  • 技术积分: 1380
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-18 22:44
个人简介

to be myself

文章分类

全部博文(59)

文章存档

2017年(5)

2013年(47)

2012年(3)

2011年(4)

分类: C/C++

2013-03-02 17:09:32

Problem: 3006  User: angrad 

Memory: 136K  Time: 250MS 

Language: C  Result: Accepted 


点击(此处)折叠或打开

  1. #include <stdio.h>

  2. int IsPrime(int a)
  3. {
  4.     int i;
  5.     if (a < 2)
  6.     {
  7.         return 0;
  8.     }
  9.     for (i=2; i*i<=a; i++)
  10.     {
  11.         if (0 == a % i)
  12.         {
  13.             return 0;
  14.         }
  15.     }
  16.     return 1;
  17. }

  18. int main()
  19. {
  20.     int a, d, n, i, count;
  21.     while(scanf("%d%d%d", &a, &d, &n) && a!=0)
  22.     {
  23.         count = 0;
  24.         for (i=a; count<n; i+=d)
  25.         {
  26.             if (IsPrime(i))
  27.             {
  28.                 count++;
  29.             }
  30.         }
  31.         printf("%dn", i-d);
  32.     }
  33.     return 0;
  34. }

2011-03-14 18:28 发表于百度空间,今搬至CU。

阅读(1184) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~