QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#3787. Ear Clipping Method

Statistics

The ear clipping method can decompose a polygon into triangles: each time, a triangle (called an "ear") is cut off along a diagonal. After $n-3$ cuts, an $n$-sided polygon is decomposed into triangles. As shown in the figure below, the triangle $\{2, 3, 4\}$ has been cut off.

Given a polygon, how can we minimize the total length of the cut traces?

Input

The input contains at most 30 test cases. The first line of each test case contains the number of vertices $n$ ($4 \le n \le 100$). The following $n$ lines describe the coordinates of each vertex of the polygon (all are integers with absolute values not exceeding 10000), arranged in counter-clockwise or clockwise order.

Output

For each test case, output the minimum total length of the cut traces, rounded to 4 decimal places.

Examples

Input 1

4
0 0
3 0
1 1
0 3
4
0 0
10 0
10 1
0 1

Output 1

Case 1: 1.4142
Case 2: 10.0499

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.