NPC2016A - Runner Game

no tags 

Today, Waca will play runner game. In this game, the player will be placed in a square-shaped arena where they will run to checkpoints of the arena.

Arena of the game is a square with a side length of N. The player will be placed in a coordinate (X, Y) inside the arena. The following are the rules of the game:

  • Player will be initially at coordinate (X, Y), where coordinate (0, 0) is the bottom left corner of the arena.
  • Then, player should run to the side of the arena to get the checkpoints.
  • Checkpoints are located in each side of the arena (top, left, bottom, right) and player should take all the checkpoints (i.e. they have to visit all sides), then go back to the initial position of the player (X, Y).
  • If the player reach the corner of the arena, he can take 2 checkpoints. For example, if a player reach coordinate (0, 0), he is considered to get the left and bottom checkpoints.

Now, Waca is curious, what is the minimum distance to get all the checkpoints and go back to his initial position? The image below is one of the possible moves for the runner game. (The red circle is Waca's initial position (X, Y).

Sample run

Input

The input will contain 3 integers, X, Y, and N.

Output

Print the minimum distance Waca need to finish the game. Your answer is considered to be correct if the difference is no more than 10-6

Example

Input:
6 4 10

Output:
28.284271

Constraints:

  • 1 ≤ N ≤ 106
  • 0 ≤ X,Y ≤ N

hide comments
nermatibhanu: 2017-06-09 15:59:06

very easy...just 5 lines code in cpp

cs_abhi2000: 2017-01-20 08:02:39

Nice one...

Last edit: 2017-01-20 09:23:59

Added by:Louis Arianto
Date:2017-01-08
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU
Resource:NPC Schematics 2016