QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 100 MB 總分: 100

#6978. 塔

统计

农夫 Jernej 在晚上感到无聊,于是他发明了一个简单的游戏。他想要用写有数字的纸片搭建一座塔。他从一张写有 $1$ 的纸片开始。

Jernej 可以在一张新的纸片上写下另一个数字,并将其放在塔顶。塔顶的新数值必须是构成该塔的连续纸片上数字的有效和。假设当前塔中有 $n$ 张纸片,他可以对塔中任意位置 $[l, u]$(其中 $1 \le l \le u \le n$)的数字求和,并将该和写在新的纸片上放在塔顶。

Jernej 想要制作 $T$ 座塔,使塔顶达到期望的数值。请帮助他找出所需的步骤,并要求最小化这些步骤的数量。

输入格式

输入的第一行包含一个正整数 $T$(Jernej 想要制作的不同塔的数量)。

接下来的 $T$ 行中,每行包含一个正整数 $q$,表示 Jernej 最终想要在塔顶达到的数值。所有游戏都是独立的。

输出格式

对于每个整数 $q$:

  • 输出一行,包含一个数字 $s$ ($0 \le s \le 1000$),表示达到期望数值所需的步骤数。
  • 在接下来的 $s$ 行中,每行应包含两个以空格分隔的正整数 $l$ 和 $u$,表示用于产生期望数值的范围边界。

数据范围

  • $1 \le T \le 1000$
  • $1 \le q \le 10^{18}$

子任务

  1. [1 个测试点 - 10 分]: $T \le 10$ 且 $q \le 10$
  2. [1 个测试点 - 10 分]: $T \le 20$ 且 $q \le 20$
  3. [1 个测试点 - 10 分]: $T \le 100$ 且 $q \le 100$
  4. [1 个测试点 - 10 分]: $T \le 1000$ 且 $q \le 10^4$
  5. [1 个测试点 - 10 分]: $T \le 1000$ 且 $q \le 10^5$
  6. [1 个测试点 - 10 分]: $T \le 1000$ 且 $q \le 10^6$
  7. [1 个测试点 - 10 分]: $T \le 1000$ 且 $q \le 10^9$
  8. [1 个测试点 - 10 分]: $T \le 1000$ 且 $q \le 10^{12}$
  9. [2 个测试点 - 20 分]: 无附加限制

评分

共有 10 个测试点,包含 $T$ 座塔。对于每个测试点,得分计算规则如下:

  • 如果你的解法对所有塔都使用了最少步骤数,则该测试点得 10 分。
  • 否则,你的得分将根据所有塔的得分最小值计算,其中单座塔的得分计算公式为 $1 + \frac{\text{minimum steps}}{\text{solution steps}} \cdot 7$,结果向上取整至小数点后两位。
  • 如果其中任意一座塔的解法无效,则该测试点得 0 分。

所有塔均有有效解。

样例

输入 1

3
2
3
7

输出 1

2
1 1
1 2
3
1 1
2 2
1 3
4
1 1
1 2
2 3
1 4

说明

在本例中 $T = 3$。

Jernej 想要找出得到 $\{2, 3, 7\}$ 所需的步骤。当前的塔仅包含一张写有 $1$ 的纸片。

第一个期望数值是 $2$。 在第一步中,他只能对范围 $[1, 1]$ 内的数字求和,因此下一张纸片上的数字只能是 $1$。 如果 Jernej 想要产生数字 $2$,他应该对范围 $[1, 2]$ 求和(选取第 $1$ 个和第 $2$ 个数字)。这将求和得到 $2$,即期望的结果。

第二个期望数值是 $3$。要产生 $3$,有多种方法。我们也可以通过以下方式产生 $3$:

1 1
1 2
2 3

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.