HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Geometry > problem:


50328 - How far away

Guest
• Review clarifications (1)

Section problems

• 50268 - Triangles
• 50663 - Lights
• 50670 - Picture
• 51041 - Plane Segmentation
• 50422 - Area and Perimeter of diffe...
• 50473 - Counting Circles Positions
• 50327 - Parallel Lines
• 50362 - Pythagorean Numbers
• 50328 - How far away
• 50397 - The Number of Points in a ...
• 50399 - Mobile Base Station
• 50487 - Radius of Inscribed Circle
• 50480 - What quadrant is it?
• 50825 - Drawing Polygon
• 50508 - The Biggest Area
• 50854 - Area of Triangle Revised
• 50669 - Area of an Irregular Polygon

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

How far away

Question: On a Cartesian coordinate system, your robot is given a series of directions: Up (U), Down (D), Right (R) or Left (L) followed by a positive integer. The robot starts from coordinate (x,y) and travels on the given direction with the given amount of steps. You are asked to find Euclidean distance from the origin (0,0).

Input specification
You are first given the starting coordinates (x,y). Starting from the next line you are given the direction (U, D, R, or L) and the number of steps (nsteps) on the given direction where 1 ≤ nsteps ≤ 100 There are at most 100000 lines in the data series and it ends with a '#' sign.

Output specification
Show a floating point number with 3 decimal place which represent the Euclidean distance from the origin.

Sample Input I
3 2
U 2
D 4
R 2
#
Sample Input II
4 6
D 5
L 7
D 2
R 2
#
Sample Output I
5
Sample Output II
1.414

Для отправки решений необходимо выполнить вход.

www.contester.ru