Toggle navigation
linghang
F.A.Qs
Web Board
ProblemSet
Source/Category
Status
Ranklist
Contest
Login
Problem1643--Prime Distance
1643: Prime Distance
Time Limit:
1
Sec
Memory Limit:
128 MB
Submit:
11
Solved:
5
[
Submit
] [
Status
] [
Web Board
] [Creator:
]
Description
给定两个整数L, R
,求闭区间[L, R]
中相邻两个质数差值最小的数对与差值最大的数对。当存在多个时,输出靠前的素数对。
Input
多组数据。每行两个数 L,R
。
Output
详见输出样例。
Sample Input
Copy
2 17 14 17
Sample Output
Copy
2,3 are closest, 7,11 are most distant. There are no adjacent primes.
HINT
对于全部数据,1 ≤ L < R < 2^31 , R-L ≤ 10^6
。
Source/Category