Polish version    English version  
  About Olympic -> Problems


 News
 About Olympic
About contest
Problems
I OI 1993/1994
II OI 1994/1995
III OI 1995/1996
IV OI 1996/1997
V OI 1997/1998
VI OI 1998/1999
VII OI 1999/2000
VIII OI 2000/2001
IX OI 2001/2002
X OI 2002/2003
XI OI 2003/2004
XII OI 2004/2005
XIII OI 2005/2006
XIV OI 2006/2007
XV OI 2007/2008
Problems archive
 History of OI
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
III Olympiad in Informatics 1995/1996

Task: PRE
Author: Piotr Chrz±stowki-Wachtel
Rods

I stage contest  

In laboratories of a certain company a new material called politoksyparen is tested. During the researches an interesting property has been discovered. A simple rod made of this material after being heated lengthens and bends so that it changes into an circular arc based on a chord, which is the shape of the rod at the beginning (this property concerns only rods of short diameters). Let’s assume that n rods with very short diameters and lengths li (1 <= li <= 100000) were used to verify this property, and while being heated they lengthened respectively by di (1 <= di <= 100), where di <= li / 2. As a unit we take one millimeter.

Task

Write a program that:

  • reads from the text file PRE.IN a number of rods n, their lengths li and increases in lengths di,
  • computes for each rod a distance between the middle of the chord and the middle of the arc after heating (assuming that politoksyparen has indeed the observed property, and rods really band into circular arcs while being heated); the result should be an integer which differs no more then 0,5 from the exact result,
  • writes the solution in the text file PRE.OUT.

Input

In the first line of the text file PRE.IN there is written one positive integer n <= 50000.
In each of the following n lines there are written two integers separated by a single space – the original length of the rod li and its increase in length during heating di.

Output

In each of n lines of the text file PRE.OUT there should be written one nonnegative integer. The integer in i-th line should be equal to the distance between the positions of the middle of the i-th rod before and after heating computed with a required accuracy (0,5 at unit).

Example

For the input file PRE.IN:
2
1000 20
15000 10

the correct answer is the output file PRE.OUT:
87
237

Your program should look for the file PRE.IN in the current directory and produce the output file PRE.OUT in the current directory too. The file containing the source code of your program should have a name PRE.???, whereas you should put three-letter abbreviation of the used programming language name instead of ???. The same program in executable form should be written in the file PRE.EXE




Print friendly version