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
2016-08-26 14:25:12
Case costed me 2 WA no diff needed just trigy :P
no double or float needed
2016-08-22 12:04:51
easy ,did'nt write case i: ,cost me 1 WA
2016-07-26 20:05:53 sssymm
Its an elementary problem.
use long long int for radius
PS: value after decimal point is fixed so use string for it.
2016-06-23 12:57:07
Only Need school level Mathametics to solve this problem(Circle)
2016-06-21 18:56:44 Anirban Acharya
For people thinking differentiation is needed to maximize the function, well its not so. In fact, its much simpler than that.
2016-06-19 09:55:22
#Fun With Mathematics
2016-06-05 22:22:59
Take radius as double and check for r=1000000 also print precision upto 2 places..wont harm you..
After soo many wa s due to these issues, finally AC!
2016-05-03 19:58:51
wrong constraints..stupid ques..cost me 1 WA...!!
took radius in int..WA
radius in double..AC
problem setter should revise his ques statement...!!

Setter reply: Constraint are perfectly fine. You submission no 16862325 have problems.


Last edit: 2016-06-03 13:16:18
2016-04-16 15:16:16 Pradd
4 lines in Python. It's more of a maths problem then programming. If you don't know differentiation, then go learn it and it's applications. It's useful for maximum and minimum calculations.
2016-02-26 03:52:07 ISHPREET
Shortest code ever use int only :)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.