LCPC12E - Johnnys Empire

no tags 

Description

Hundreds of years ago Johnny's father had a great kingdom. Before his death he divided his kingdom between his sons (Johnny and Johnny's brother). Johnny's brother took part of the kingdom with a circular shape with radius R.  Jonny took part of kingdom of squared shape with side length L. As Johnny was jealous from his brother after his father's death, he decided to extend his kingdom to be a circle such that the corners of the square lies exactly on the border of the circle. A problem might occur that Johnny could steal some land from his brother, and that could wage a huge war between the two brothers. So Johnny decided to convince his brother to build a wall separating between the two kingdoms. The wall should be connecting the two intersection points between the two circles. You are to estimate the length of this wall.

Input Format

The first line of input contains an integer T, the number of test cases. T test cases follow, the first line of each test case contains 6 floating point numbers; 2 numbers denoting the center of Johnny's brother kingdom, another 2 for the center of Johnny's kingdom, R the radius of Johnny's brother kingdom A, and L the side length of the square of Johnny's kingdom. It’s guaranteed that both kingdoms don’t share any lands originally. Also after kingdom B is extended, it’s guaranteed that the intersection area will not cover Johnny's brother kingdom completely. The absolute value for all decimal numbers will be less than 109.

Output Format

There should be T lines, containing the following format.

k. S

Where k is the test case number (starting at 1), a single period, a single space and S represent a decimal number with exactly 3 digits after the decimal point representing the wall length. If there’s no possibility of war, print “No problem”.

Sample Input

Sample Output

3
0.0 0.0 10.0 0 3 3
0.0 0.0 4.121 0 3 3
-1 3 1 -1 2 7.071
1. No problem
2. 2.971
3. 3.994

 


hide comments
nadstratosfer: 2017-09-15 00:56:27

Complex solution derived from Heron's formula will get WA, look for much simpler way. Chop off the decimals, not round in Python. No blanklines in input and none in output.

mathador: 2016-08-22 21:41:29

easy peasy :)

mmz33: 2016-08-22 21:41:23

No need for long double, double will work.

Jatin Narula: 2015-07-28 22:22:42

double would do......

Mendel: 2015-02-15 17:54:40

input doesnt have any blank line but print a blank line for the output

darol: 2015-02-06 21:32:30

Make sure to include empty line between output cases, costed me 2 wa.

Last edit: 2015-02-06 21:33:33
Abhinandan Agarwal: 2015-01-12 16:02:39

USE long double, costs two 2WA before enlightenment

Crazy Monk : 2014-12-29 19:04:41

use scanf/printf instead of cin/cout ... cost me 4 WA's -_-

Diksha Jaiswal: 2014-06-27 08:10:14

simple maths :)

abhay srinivas: 2014-06-14 11:29:50

made stupidest mistakes of my life..


Added by:Gareev
Date:2012-10-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:LCPC 2012