Programming contests

Magas szintű programozási nyelvek 1, gyakorló feladatsor, 2012. március 20.

March 20, 2012 3:00 PM – April 21, 2012 12:00 AM

The Grazing Cow

A cow is grazing in the field. A rope in the field is tied with two pillars. The cow is kept tied with the rope with the help of a ring. So the cow can be considered to be tied with any point of the rope. Your job is to find the area of the field where the cow can reach and eat grass. If required assume that π = 2 × cos−1(0) (here angle is measured in radians). You can also assume that the thickness of the rope is zero, the cow is a point object and the radius of the ring and the thickness of the pillars are negligible. Please use double precision floating-point data type for floating-point calculations.

Input Specification

First line of the input file contains an integer (N ≤ 100), which indicates how many sets of inputs are there. Each of the next N lines contains two integers D (0 ≤ D ≤ 1000) and L (D < L ≤ 1500). The first integer D denotes the distance in feet between the two pillars and the second integer L denotes the length of the rope in feet.

Output Specification

Your program should produce N lines of output. Each line contains a single floating-point number, which has three digits after the decimal point. This floating-point number indicates the area of the field which the cow can reach and eat grass.

Sample Input

  1. 3
  2. 10 12
  3. 23 45
  4. 12 18
download as text file

Output for Sample Input

  1. 62.517
  2. 1366.999
  3. 189.670
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019