QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB

#22992. 折叠卷尺

Statistics

一条透明卷尺上有六个互不相同的整数位置被标记:两个红色、两个蓝色、两个黄色。先折叠卷尺使红色标记重合,再折叠所得卷尺使蓝色标记重合,最后使黄色标记重合。如果接下来要处理的一对标记已经重合,则保持卷尺不变。

求折叠后卷尺的长度。

输入格式

第一行包含原长 $L$,单位为厘米,满足 $10\le L\le1000$。

接下来三行分别包含红色、蓝色和黄色两标记的位置。六个位置均为卷尺上互不相同的整数位置,从卷尺起点量起。

输出格式

输出最终长度,恰好保留小数点后一位,必要时补上末尾的零。

样例

输入格式 1

10
2 7
5 4
10 3

输出格式 1

3.5

说明

卷尺初始长度为 $10$ 厘米。红色标记在 $2$ 厘米和 $7$ 厘米处,蓝色标记在 $5$ 厘米和 $4$ 厘米处,黄色标记在 $10$ 厘米和 $3$ 厘米处。

problem_22992_a50d3f6067b146dfec2d61af0c58d6ff.png

带有六个彩色标记的原始卷尺

第一次在 $4.5$ 厘米处折叠。两部分的长度为 $4.5$ 厘米和 $5.5$ 厘米,因此折叠后的卷尺长 $5.5$ 厘米。蓝色标记已经重合,所以跳过第二次折叠。再折叠使黄色标记重合后,卷尺长 $3.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.