#abc375b. B - Traveling Takahashi Problem
B - Traveling Takahashi Problem
Score : points
问题陈述
高桥在二维坐标平面的原点上。
他从点 移动到点 的成本是 。
当他从原点开始,按顺序访问 个点 ,然后返回原点时,找出总成本。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
Takahashi is at the origin on a two-dimensional coordinate plane.
The cost for him to move from point to point is .
Find the total cost when he starts at the origin, visits points in this order, and then returns to the origin.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Your output will be considered correct if its absolute or relative error from the true value is at most .
Sample Input 1
2
1 2
-1 0
Sample Output 1
6.06449510224597979401
The journey consists of the following three steps:
- Move from to . The cost is $\sqrt{(0 - 1)^2 + (0 - 2)^2} = \sqrt{5} = 2.236067977...$.
- Move from to . The cost is $\sqrt{(1 - (-1))^2 + (2 - 0)^2} = \sqrt{8} = 2.828427124...$.
- Move from to . The cost is .
The total cost is .
Sample Input 2
7
-14142 13562
-17320 50807
-22360 67977
24494 89742
-26457 51311
28284 27124
31622 77660
Sample Output 2
384694.57587932075868509383
Sample Input 3
5
-100000 100000
100000 -100000
-100000 100000
100000 -100000
-100000 100000
Sample Output 3
1414213.56237309504880168872