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
rohit9934:
2017-05-08 12:16:19
Pre-Requisites: High school differentiation. |
|
soodan:
2017-04-08 12:31:08
Few points to take care of :
|
|
sushanth_r:
2017-03-29 16:27:25
1 WA because of the output format. My fault, I know. |
|
ANKIT JAIN:
2017-03-24 15:16:01
AC in one go :) |
|
vladimira:
2017-02-21 22:25:52
For python-ers. There are some extra spaces or something else with input is wrong. So try to read input not by lines but by words. For example sys.stdin.read().split(). In advance if you will use this trick further, it is bad way if input is large, so bufferize. |
|
nilabja16180:
2017-02-16 08:18:19
11 Lines of Code AC in one GO! |
|
splashishkumar:
2017-01-30 14:08:05
AC in one go...think only 5 minute
|
|
anup2raj:
2017-01-19 16:36:14
giving wa from r=1024
|
|
narutohokage_1:
2017-01-17 06:36:16
long int can also be 32 bit on your compiler so it could also not work , please use long long int. Input cases are only integer, what happens is it overflows more than what int can contain , no need to use floating point or double. |
|
narutohokage_1:
2017-01-17 06:20:03
TO ALL WHO FOUND output confusing , first of all radius given are in integer only no float , and yes the problem is as easy as you are thinking . Second if you take radius as integer and it is not accepting , it is because (for C) , int max size can be of 4,294,967,295 and if r = 1000000 , r * r = 1000000000000 which is above the range of int , so use long long in C. Format Specifier is %lld , that is all it is to this problem. Constant time is for any test case. |
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) |