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
anon_007:
2019-06-23 09:00:01
use of setprecision is must costed me 4 WAs... |
|
aj_254:
2019-05-23 21:48:52
5 line code in python remember output format cose me one WA. very easy qusetion just need to diffretiate |
|
pandey101299:
2019-02-08 13:52:56
Easy one but use double for sum |
|
cypher33:
2019-01-04 17:17:34
Stupid Output format costed me 2 WA.... That was fair dinkum pain in the butt |
|
prabhav_123:
2019-01-02 22:36:09
\n costed me 1 WA, LOL! |
|
saket13:
2018-08-29 21:17:39
Be aware of the output format(Case 1: ans)
|
|
akjol2049:
2018-08-23 20:10:10
OMG...just (2*r)^2 and 0.25. Always the case:). As limit of angle between AB and diagonal approaches to 180. |
|
theabd123:
2018-06-01 07:29:21
Use double data type.....simple differentiation |
|
imkiller:
2018-05-30 20:37:07
5 lines Simple Maths
|
|
sharmajatin741:
2018-05-15 09:12:38
Easy , AC in one go! |
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) |