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
hide comments
|
Tarun Garg:
2013-11-30 15:51:34
output formatting cost 2 WA...Case(space)I:(space)no. |
|
Dinesh:
2013-11-16 22:46:00
haha..i/o practice..:) |
|
Abhishek Pasayat:
2013-11-06 18:32:31
why cant we take "s" as float??Its working for "s" as double but not for float. |
|
Shashank Gupta:
2013-11-06 01:57:57
Hint: Read wikipedia articles on "Thales' theorem" and "Quadratic functions". Also, know how to handle large integers in whatever language you are in. :) Good problem. |
|
Kyuubi Sage Mode:
2013-10-30 20:36:39
i ignored the formatting like case #x: ans somehow and that cost me 2 WAs :P |
|
Aswin Murugesh:
2013-09-15 21:11:58
One liner in python. Solved it with just a simple trick for decimal place |
|
KESHAV BANSAL:
2013-08-13 15:49:48
Got WA Due to Case(c)in capital
|
|
Rudradeep Mukherjee:
2013-07-12 15:04:05
Got WA due to different data types. Got AC in 2nd attempt ! :) |
|
Hasil Sharma:
2013-07-02 11:52:26
yeah true , it can be solved without using any float or double |
|
pika_pika:
2013-06-28 13:35:00
really should be moved to tutorial. The wrong output format costed me 2 WA.. just a whitespace missing and the spoj engine goes of crazy... :P |
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) |