#P6973. [NEERC2016] List of Primes

[NEERC2016] List of Primes

题目描述

Lidia likes sets of prime numbers. When she is bored, she starts writing them down into the Extremely Long Notebook for Prime Sets.

Elements of each set are written down in ascending order. Each set of prime numbers appears in her notebook eventually. A set with a smaller sum always appears before a set with a larger sum. Sets with the same sum are sorted in ascending lexicographical order: they are compared by the first element, if the first elements are equal, then by second element, and so on.

Just in case someone decides to parse her notebook, she writes down her sets in a machine-readable JSON format. Of course, she puts a space after each comma. Here's the beginning of her notebook:

$[2], [3], [2 , 3], [5], [2 , 5], [7], [3 , 5], [2 , 7], [2 , 3 , 5], [3 , 7], [11], [2 , 3 , 7], [5 , 7], [2 , 11], [13], [2 , 5 , 7],$

Lidia wants to double-check her work, so here is her request for you: given two integers, aa and bb , output a substring of her notebook from the position aa to the position bb (inclusive, counting from 11) .

输入格式

The first line contains two integers, aa and bb (1ab1018;ba1051 \le a \le b \le 10^{18}; b - a \le 10^{5}).

输出格式

Output the substring of the notebook described in the problem statement from the position aa to the position bb . You must write a line with exactly ba+1b - a + 1 characters, including any leading or trailing spaces.

题目大意

Lidia 喜欢素数集。当她无聊时,她就把它们写进她的「素数集的超长笔记本」。

集合中的元素按升序排列。每个集合都会在她的笔记本里出现,且以元素和为第一关键字,字典序为第二关键字排列。

为了预防有人决定解析她的笔记本,她把她的集合写成了机器可读的 JSON 格式。当然,她在每个逗号后面都加了空格。以下是她的笔记本的开头:

$$[2], [3], [2 , 3], [5], [2 , 5], [7], [3 , 5], [2 , 7], [2 , 3 , 5], [3 , 7], [11], [2 , 3 , 7], [5 , 7], [2 , 11], [13], [2 , 5 , 7], $$

Lidia 想仔细检查她的工作,所以她给了你两个整数 aabb,要你输出她的笔记本中第 aabb 个字符(含两端,从 11 开始)的内容。

1 35

[2], [3], [2, 3], [5], [2, 5], [7],

36 41

 [3, 5

提示

Time limit: 2 s, Memory limit: 512 MB.