MAXLN - THE MAX LINES

In this problem you will be given a half-circle. The half-circle’s radius is r. You can take any point A on the half-circle and draw 2 lines from the point to the two sides of the diameter(AB and AC). Let the sum of square of one line’s length and the other line’s length is s

Like in the figure s = AB2 + AC. And BC = 2r.

Now given r you have to find the maximum value of s. That is you have to find point A such that AB2 + AC is maximum.

Input

First line of the test case will be the number of test case T (1 <= T <= 1000). Then T lines follows. On each line you will find a integer number r (1 <= r <= 1000000); each representing the radius of the half-circle.

Output

For each input line, print a line containing "Case I: ", where I is the test case number and the maximum value of s. Print 2 digit after decimal (Errors should be less then .01).

Example

Sample Input:
1
1

Sample Output:
Case 1: 4.25

Added by:Muhammad Ridowan
Date:2011-03-28
Time limit:1s-1.679s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem(used for CSE,University of Dhaka, Newbies Contest)

hide comments
2021-11-16 11:41:02
AC AFTER 5 WA
JUST SIMPLE NO NEED TO TAKE DOUBLE OR FLOAT
USE LONG LONG INT
2021-07-04 13:30:45 Waseem Ahmed
Simple one line answer. Not a SPOJ level problem. Disheartened.

Hint : Read comments from users "carefully". Especially one user.

[NG]: You've been banging for half an hour to get AC in this "simple" problem, then you're whining about how disappointing it was -- like in every other one you solved. Try a problem with less than 5000 solvers sometime, then you'll be qualified to speak of this "SPOJ level" mystery that you keep referring to.

Last edit: 2021-07-04 20:42:34
2020-10-18 08:07:40
can i some one tell me why it works for double and not for float.
2020-07-23 15:16:20
try making 180 degree.. and for the second line look at the given sample test case!!!
2020-06-30 13:20:26
In CPP, by default, big numbers will be printed in an "e" format. So, make sure that you do this to match the output format :
cout<<fixed;
cout<<setprecision(2);
2020-05-29 17:11:28
Java Bois be careful with this one! :-)
2020-05-21 10:12:08
Try long double. The value is fixed for AC. Try to find it. Use iomanip for setting precision and fixed for normal format.

Last edit: 2020-05-21 10:12:35
2019-12-27 13:02:29
Use joseph louis theorem, AC in one go
2019-10-12 02:34:29 Saurav Singhi
spoiler alert for java. 1 WA for not remembering java's default typecasting during evaluation of regular expressions.
2019-07-10 10:39:04
if you got the logic then use of double ,float not required


Last edit: 2019-07-10 10:40:43
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.