Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4610
  • 博文数量: 8
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-19 08:24
文章分类

全部博文(8)

文章存档

2014年(8)

我的朋友
最近访客

分类: C/C++

2014-11-19 09:29:26


  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <iostream>
  6. using namespace std;

  7. int isok(int x)
  8. {
  9.     double xx = (double)x;
  10.    for(int i = (int)sqrt(xx); i > 1; i--)
  11.      if(x%i == 0)return 0;
  12.    return 1;
  13. }

  14. int main()
  15. {
  16.     int n;
  17.     while(scanf("%d", &n) != EOF && n)
  18.     {
  19.         int x;
  20.         int ans = 0;

  21.         for(int i = 2; i < n/2; i++)
  22.         {
  23.             if(isok(i) && isok(n-i))
  24.                 ans++;
  25.         }
  26.         printf("%d\n", ans);
  27.     }
  28.     return 0;
  29. }

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