Loading [MathJax]/jax/output/CommonHTML/jax.js

Problem E. Emitting light

Author:A. Klenin   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  

Statement

Young physicist Masha studies lasers. Masha wants to create a simplest 2-dimensional waveguide, consisting of two very long parallel mirrors, one coinciding with the Ox axis, and another located h millimeters above the first.

Masha's laser is located at coordinates (0,y) and emits light in direction (1,1). Masha wants to hit a target located at coordinates (xt,yt) by choosing a good value for h. All coordinates are in millimeters.

Note that laser itself must fit into the waveguide, so hy. Both mirrors and laser are perfect, so light is always fully reflected at 45 degrees angle.

Input file format

Input file contains three integers yxtyt — coordinates of laser and target.

Output file format

Output file must contain a single integer — value of h. If there are several solutions, output the smallest one. If there are no solutions, output 1.

Constraints

1y,xt,yt109

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
5 2 2
-1
2
5 6 1
5
3
2 16 2
2

0.062s 0.008s 13