CF237C.Primes on Interval
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.
Consider positive integers a, a + 1, ..., b (a ≤ b). You want to find the minimum integer l (1 ≤ l ≤ b - a + 1) such that for any integer x (a ≤ x ≤ b - l + 1) among l integers x, x + 1, ..., x + l - 1 there are at least k prime numbers.
Find and print the required minimum l. If no value l meets the described limitations, print -1.
你决定开展一项关于素数理论的调查。我们提醒你,素数是指恰好有两个不同正整数约数的正整数。
考虑正整数 a, a+1, ..., b(其中 a≤b)。你需要找出最小的整数 l(满足 1≤l≤b−a+1),使得对任意整数 x(满足 a≤x≤b−l+1),在 l 个连续整数 x, x+1, ..., x+l−1 中至少包含 k 个素数。
求出并输出所要求的最小 l。若不存在满足上述条件的 l,则输出 −1。
输入格式
A single line contains three space-separated integers a, b, k (1 ≤ a, b, k ≤ 106; a ≤ b).
一行包含三个以空格分隔的整数 a、b、k(1 ≤ a, b, k ≤ 106;a ≤ b)。
输出格式
In a single line print a single integer — the required minimum l. If there's no solution, print -1.
在一行中输出一个整数——所需的最小 l。若无解,输出 -1。
输入输出样例
输入#1
2 4 2
输出#1
3
输入#2
6 13 1
输出#2
4
输入#3
1 4 3
输出#3
-1
输入解题思路,AI测评打分。不知道怎么写?