#P12130. Minimum Distance to Destination

    ID: 14229 Type: Default 1000ms 256MiB

Minimum Distance to Destination

Minimum Distance to Destination

Little Ming starts at the origin of a 2D plane and wants to reach the point \((233,\ 666)\). He can only use the following two types of moves (in any order, any number of times):

  1. A horizontal move to the right, i.e. moving some distance along the positive x-axis.
  2. A circular arc move along the circumference of the circle centered at \((0,0)\) with radius equal to his current distance from the origin. In this move the direction (clockwise or anticlockwise) is arbitrary.

Under these conditions, what is the minimum total distance he must move in order to reach his destination? Output the answer rounded to the nearest integer.

Hint: Let \(r=\sqrt{233^2+666^2}\) be the distance from the origin to the destination and \(\varphi=\arctan(666/233)\) be the angle of the destination in polar coordinates. One optimal strategy is:

1. Move horizontally from \((0,0)\) to \((r,0)\), incurring a distance of \(r\).
2. Then move along the circular arc from \((r,0)\) to \((233,666)\) with an arc length of \(r\varphi\).
The total distance is \(r(1+\varphi)\), and the final answer should be the nearest integer to this value.

inputFormat

This problem does not require any input.

outputFormat

Output a single integer — the minimum distance that must be traveled, rounded to the nearest integer.

sample

1577