QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#7820. Black and White Square

Estadísticas

A square sheet of paper lies on a table, with its top side black and its bottom side white. On each side of the square, a point is marked. Without lifting the sheet from the table, the paper is folded along line segments connecting points on adjacent edges, folding the corners inward in an arbitrary order. Naturally, a situation may arise where a previously folded corner is folded again along with another corner that it has overlapped.

After all the folds, a polygon is formed, consisting of black and white regions, which is then pinned to the table with a thumbtack.

Determine the area of the black region, as well as the maximum possible number of layers of paper that the thumbtack can pierce.

Input

The first line contains 5 positive integers separated by spaces: $N$ — the side length of the square sheet of paper, $2 \le N \le 1000$, $Y_L$ — the $Y$-coordinate of the point on the left side of the square, $Y_R$ — the $Y$-coordinate of the point on the right side of the square, $X_B$ — the $X$-coordinate of the point on the bottom side of the square, and $X_T$ — the $X$-coordinate of the point on the top side of the square. The square is positioned parallel to the coordinate axes, the $X$-axis points to the right, the $Y$-axis points upward, and the bottom-left corner of the square is at the origin.

Output

The first line should contain a single real number with 3 decimal places of precision — the area of the black region of the polygon resulting from the folding of the paper.

The second line should contain the maximum number of layers of paper that can be pierced by the thumbtack, pinning the resulting polygon. The puncture point must not fall on the edges of the sheet or on the fold lines.

Examples

Input 1

10 4 6 6 2

Output 1

3.085
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.