Twin primes are pairs of primes of the form (p, p + 2). The term “twin prime” was coined by Paul Stckel (1892-1919). The first few twin primes are (3, 5), (5, 7), (11, 13), (17, 19), (29, 31), (41, 43). In this problem you are asked to find out the S-th twin prime pair where S is an integer that will be given in the input.
Input
The input will contain less than 10001 lines of input. Each line contains an integers S (1 ≤ S ≤ 100000), which is the serial number of a twin prime pair. Input file is terminated by end of file.
Output
For each line of input you will have to produce one line of output which contains the S-th twin prime pair. The pair is printed in the form (p1,¡space¿p2). Here ¡space¿ means the space character (ASCII 32) . You can safely assume that the primes in the 100000-th twin prime pair are less than 20000000.
Sample Input
1
2
3
4
Sample Output
(3, 5)
(5, 7)
(11, 13)
(17, 19)

问题链接:UVA10394 Twin Primes
问题简述:(略)
问题分析
    孪生素数问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10394 Twin Primes */#include <bits/stdc++.h>using namespace std;const int N = 20000000;
bool isprime[N + 1];
int prime[N / 3], pcnt = 0, twprime[N / 9], twcnt = 1;
// 欧拉筛
void eulersieve(void)
{memset(isprime, true, sizeof(isprime));isprime[0] = isprime[1] = false;for(int i = 2; i <= N; i++) {if(isprime[i])prime[pcnt++] = i;for(int j = 0; j < pcnt && i * prime[j] <= N; j++) {  //筛选isprime[i * prime[j]] = false;if(i % prime[j] == 0) break;}}prime[pcnt] = 0;for(int i = 0; i < pcnt; i++)if(prime[i] + 2 == prime[i + 1]) twprime[twcnt++] = prime[i];}int main()
{eulersieve();int n;while(~scanf("%d", &n))printf("(%d, %d)\n", twprime[n], twprime[n] + 2);return 0;
}

UVA10394 Twin Primes【孪生素数】相关推荐

  1. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  2. 张益唐的孪生素数证明

    张益唐的孪生素数证明 文章目录 张益唐的孪生素数证明 前言 第一章:孪生素数的历史与问题 第二章:张益唐的思路与方法 张益唐的孪生素数证明过程 第三章:张益唐的贡献与成果 第四章:孪生素数的意义和影响 ...

  3. UVa 10394-Twin Primes

    2019独角兽企业重金招聘Python工程师标准>>> [问题描述] Twin primes are pairs of primes of the form (p, p+2). Th ...

  4. Extended Twin Composite Number 思维题

    Do you know the twin prime conjecture? Two primes a and b are called twin primes if a+2=b. The twin ...

  5. 判断是否为质数的超级优化 C++语言(超详细)

    首先我们要知道质数的概念: 质数(prime number)又称素数,有无限个.质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数. 知道了质数的概念,我们就可以大胆的说:"老师 ...

  6. 求质数(Prime Number 素数)的方法——厄拉多塞筛法

    质数又称素数.指在一个大于1的自然数中,除了1和此整数自身外,没法被其他自然数整除的数.换句话说,只有两个正因数(1和自己)的自然数即为素数.比1大但不是素数的数称为合数.1和0既非素数也非合数.合数 ...

  7. 陈景润学术地位无人可及

    陈景润学术地位无人可及 本文附件是筛法英文维基的的原文.文中作者把陈景润1+2定理看做是哥德巴赫与孪生素数两个猜想的"近乎无误"(near-misses)的数学证明,陈景润的学术地 ...

  8. 计算机解题报告,计算机题目33题(附带题解)精选.doc

    第1~10题为基础题,第11~20题为提高题,第21~33为综合题 每位同学分别从基础题.提高题.综合题中各选一题,按学号顺序循环选择,用word写报告.每班评出优秀的9名同学,上台做报告,每人期末成 ...

  9. π-Algorithmist分类题目(1)

    原题网站:Algorithmist,http://www.algorithmist.com/index.php/Main_Page π-Algorithmist分类题目(1) Sorting UVAL ...

最新文章

  1. Kubernetes源码阅读笔记——Controller Manager(之三)
  2. 一篇文章教你弄懂 SpringMvc中的HandlerInterceptor
  3. push方法java_万字长文深入浅出谈Java数据类型系列之Stack
  4. PHP的getimagesize获取图像信息
  5. nginx 修改配置文件使之支持pathinfo,且隐藏index.php
  6. java异常—— finally 子句+带资源的 try语句
  7. 快速提示:使用Chrome开发工具调试GWT应用程序
  8. CM3计算板I/O编程
  9. 安卓mysql修改_手动修改Android数据库数据
  10. sql server 用户创建与权限管理
  11. python机器学习-糖尿病数据挖掘
  12. 计网实验三 虚拟局域网 VLAN
  13. win10磁盘分区时无法删除卷解决办法
  14. tensorflow量化感知训练_TensorFlow 8 bit模型量化
  15. 序列化器serializers的使用
  16. 理解Java并发编程:CountDownLatch解析
  17. DNSpod+安全宝+360网站卫士的双CDN加速服务
  18. chart.js画图
  19. VII python(1)基础知识
  20. mdpi的手机_APP设计尺寸

热门文章

  1. GDAL库读取Envisat ASAR数据
  2. 使用GDAL库中的RPC校正问题
  3. .net core 多平台开发体验
  4. Flex Builder 3 下载与注册
  5. 深入Managed DirectX9
  6. DataSet运用DES加解密到Xml
  7. Mysql中循环拼接参数_利用循环向数据库中插入数据,参数重复的问题
  8. 段错误 php,如何解决php扩展出现段错误的问题
  9. 机器学习之监督学习(五)——集成学习(Boosting)
  10. Qt总结之十五:QByteArray详解