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
RIVU DAS: 2014-02-12 14:22:52

That was quite easy and nice!!

Andrey Maksimenko: 2013-10-21 14:49:31

AC only when used long double and %Lf for scanf/printf. Many stupid WA's because of that. Thanks for problem! Learned some!

nitish rao: 2013-08-16 06:09:40

@admin can u plz check my solution 9848773 donno why i m getting WA. Thank you

Anant Kumar: 2013-08-15 11:39:56

Accepted in one go. Just a mathematical problem.

Hariharan : 2013-07-11 19:08:36

Easy one :-) My Half Century with this one. :-)
Just be careful with the precision, cost me a WA. :-(

Last edit: 2013-07-11 19:09:24
Vaibhav Agarwal: 2013-07-05 19:50:16

use of floats in python gives me AC but decimal doesn't..... :(

shiva_hellgeek: 2013-06-03 18:23:30

This problem brings up my double century... :D

Shubham Sharma: 2013-05-27 17:30:10

Getting right answers for the given inputs but still getting wa . plzz help someone

Himanshu: 2013-03-22 05:49:33

easy one..

3qu@t!0n: 2012-12-14 06:37:28

someone please can suggest exact input and output format......


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