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
cc:
2011-10-10 16:08:41
for c++ users: use int for the test case, long long int for the radius, and double for the result :) |
|
Nnavneetsinha:
2011-09-24 06:10:02
some mathematics needed only.
|
|
manish kapoor:
2011-07-28 10:30:22
my code runs fine for d given test case ,pls give sm more test cases....pls (sm odd ones) |
|
oldmonk:
2011-06-12 19:08:36
do some math to get value of AC.. :) Last edit: 2011-06-12 19:09:02 |
|
Rohan Laishram:
2011-06-02 08:39:11
Tutorial |
|
Piotr KÄ…kol:
2011-05-22 11:00:33
@arshak minasyan - Yup. |
|
arshak minasyan:
2011-05-22 09:15:53
is the answer for r=2 16.25? |
|
Piotr KÄ…kol:
2011-05-12 15:59:03
@sikandar - That for example if the answer is 1.23 You can print both 1.229 and 1.231 as it's both rounded to 2 decimal point 1.23. |
|
sikandar:
2011-05-12 10:57:29
what means Errors should be less then .01 ?
|
|
:(){ :|: & };::
2011-04-17 00:03:36
Tutorial material. |
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) |