题目:
• 题意:
给出一个正整数k,找到与之相邻的两个素数,并求出两个素数之差。如果不存在两个相邻的素数则输出0。
限制: 1<=k<=1299709
• 分析:
有一个结论,素数的分布相对密集,在10^9以内,两个相邻素数距离不超过400 ,所以可以直接向前和向后枚举素数
代码:
// Problem#: 1500
// Submission#: 5124813
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Su