QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100

#9497. 青蛙与传送门

الإحصائيات

一只小青蛙想要到达河的对岸。青蛙最初位于河的一岸(位置 $0$),想要到达另一岸(位置 $200$)。幸运的是,河上有 $199$ 片荷叶(从位置 $1$ 到位置 $199$),青蛙可以在荷叶之间跳跃。当青蛙位于位置 $p$ 时,它可以跳到位置 $p+1$ 或 $p+2$。

小青蛙有多少种不同的方式可以到达位置 $200$ 的岸边?这是一个经典问题。其解为斐波那契数列的第 $201$ 项。斐波那契数列的构造如下:$F_1 = F_2 = 1; F_n = F_{n-1} + F_{n-2}$。

现在你可以在荷叶上建造一些传送门。对于每一片荷叶,你可以选择是否在上面建造传送门。并且你需要为每个传送门设置一个目的地。当青蛙到达一个有传送门的荷叶时,它会立即被传送到相应的目的地。如果目的地也有传送门,青蛙会立即再次被传送。如果某些传送门的目的地形成了一个环,青蛙将被永久困在里面。注意,你不能在同一片荷叶上建造两个传送门。

你能否建造传送门,使得小青蛙从位置 $0$ 到达位置 $200$ 的不同路径数量为 $M$?

输入格式

输入包含不超过 $100$ 组测试数据。 每组测试数据包含一个整数 $M$,表示小青蛙从位置 $0$ 到达位置 $200$ 的路径数量。$(0 \le M < 2^{32})$

输出格式

对于每组测试数据: 第一行包含一个数字 $K$,表示传送门的数量。 接下来 $K$ 行,每行包含两个数字 $a_i$ 和 $b_i$,表示你在位置 $a_i$ 放置了一个传送门,它会将青蛙传送到位置 $b_i$。 你需要保证 $1 \le K, a_i, b_i \le 199$,且当 $i \neq j$ 时 $a_i \neq a_j$。如果存在多种方案,输出其中任意一种即可。

样例

输入格式 1

0
1
5

输出格式 1

2
1 1
2 1
2
1 199
2 2
2
4 199
5 5

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.