QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#4876. 炸弹

統計

恐怖分子无处不在,他们总是通过引爆炸弹来制造麻烦。恐怖分子有一些火药可以用来制造炸弹,不同的火药有不同的威力,每种火药都可以使用多次,而一个炸弹的威力是其所包含的火药威力之积。让我们看看他们是如何制造炸弹的。

起初,他们决定使用 $X$ 个火药部件来制造一个炸弹,然后选择 $X$ 个火药,除了第一次选择外,每次选择的火药威力都不能小于上一次选择的火药威力。在选择了 $X$ 个火药部件后,恐怖分子得到 $gunpowder[1], gunpowder[2], \dots, gunpowder[X]$(满足 $gunpowder[1] \le gunpowder[2] \le \dots \le gunpowder[X]$),然后将这 $X$ 个火药混合,生成一个威力为这些火药威力之积的炸弹。恐怖分子按一定顺序制造炸弹,如果他们在制造炸弹 B 之前制造了炸弹 A,则必须满足以下条件之一:

  • 恐怖分子制造炸弹 A 所使用的火药部件数量少于炸弹 B。
  • 恐怖分子制造炸弹 A 和炸弹 B 时使用的火药部件数量相同。存在一个整数 $j$ ($j \le X$),使得对于所有 $i < j$,都有 $gunpowder\_A[i] = gunpowder\_B[i]$,且 $gunpowder\_A[j] < gunpowder\_B[j]$。

现在,警方通过某种方式获得了火药,警方发现火药的威力在 $A$ 到 $B$ 的范围内(包含 $A$ 和 $B$),警方想知道威力在 $L$ 到 $R$ 范围内(包含 $L$ 和 $R$)的第 $K$ 个炸弹。

输入格式

输入包含多组测试数据。第一行是一个整数 $T$,表示测试数据的组数。对于每组数据,一行包含五个整数 $A, B, L, R, K$。$A, B$ 表示火药的威力范围,$L, R$ 表示炸弹的威力范围,$K$ 表示警方想要查询的第 $K$ 个炸弹。

$2 \le A \le B \le 10^6$ $1 \le L \le R \le 10^9$ $1 \le K \le 10^6$

输出格式

对于每组数据,第一行输出格式为 “Case #x: y”,其中 $x$ 是从 1 开始的测试数据编号,$y$ 是炸弹的威力;第二行输出他们选择的火药(按选择顺序)。如果威力在 $L$ 到 $R$ 范围内的炸弹不足 $K$ 个,则仅输出一行 “Case #x: -1”。

样例

样例输入 1

4
2 2 1 4 1
2 5 1 4 4
73 23642 12 20903 29401
2 50 1 1000000000 815180

样例输出 1

Case #1: 2
2
Case #2: 4
2 2
Case #3: -1
Case #4: 59200
4 4 5 20 37

说明

在第二组样例中,我们有 4 种威力分别为 2, 3, 4, 5 的火药。 第一个炸弹是 “2”,威力为 2 第二个炸弹是 “3”,威力为 3 第三个炸弹是 “4”,威力为 4 第四个炸弹是 “5”,威力为 5 第五个炸弹是 “2 2”,威力为 $2 \times 2 = 4$ 因此,威力在 1 到 4 范围内的第 4 个炸弹是 “2 2”。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.