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
Seshadri R:
2011-04-15 04:50:59
@cegprakash: For a circle of radius 1, the maximum value of s (s=AB*AB + AC) is 4.25.
|
|
enchantress:
2011-04-11 19:08:20
i am getting WA altho the answer for the given test case is correct . |
|
cegprakash:
2011-04-06 01:05:04
could someone explain the given testcase? |
|
Siarhei Khamenka:
2011-03-30 13:03:37
Did you add "Case I :" before the answer ? |
|
neophilic:
2011-03-30 05:48:24
@seshadri: I know that, and as I said earlier, algo is too trivial for a classic problem. But still I was getting WA because of a silly mistake. Last edit: 2011-03-30 05:54:54 |
|
Seshadri R:
2011-03-30 04:29:01
@neophilic: While the inputs are all integers, the result is not. That might be the reason for your WA (I am telling this from my personal experience) |
|
Seshadri R:
2011-03-30 04:27:38
Pre-university knowledge of calculus would enable any kid to write the simplest of programs to solve this problem. Tutorial candidate? |
|
যোবায়ের:
2011-03-28 13:41:04
@neophilic for discussing about algorithms and test cases, please go to spoj forums. |
|
Muhammad Ridowan:
2011-03-28 11:48:42
Any comment regarding wanting result for any test case will be removed. As some people already accepted it , I think its pointless. |
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) |