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.