MAXLN - THE MAX LINES

no tags 

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

hide comments
tni_mdixit: 2016-08-26 14:25:12

Case costed me 2 WA no diff needed just trigy :P
no double or float needed

kaushivam: 2016-08-22 12:04:51

easy ,did'nt write case i: ,cost me 1 WA

sssymm: 2016-07-26 20:05:53

Its an elementary problem.
use long long int for radius
PS: value after decimal point is fixed so use string for it.

baadshah_: 2016-06-23 12:57:07

Only Need school level Mathametics to solve this problem(Circle)

Anirban Acharya: 2016-06-21 18:56:44

For people thinking differentiation is needed to maximize the function, well its not so. In fact, its much simpler than that.

hassanarif63: 2016-06-19 09:55:22

#Fun With Mathematics

pranjalikumar9: 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!

rohittt: 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
Pradd: 2016-04-16 15:16:16

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.

ISHPREET: 2016-02-26 03:52:07

Shortest code ever use int only :)


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)