no tags 

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.


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.


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).


Sample Input:

Sample Output:
Case 1: 4.25

hide comments
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!

Rahul Kathuria: 2018-11-19 13:20:13


Last edit: 2018-11-19 13:26:03
saket13: 2018-08-29 21:17:39

Be aware of the output format(Case 1: ans)
Costed me two WAs..

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
Python3 :)

sharmajatin741: 2018-05-15 09:12:38

Easy , AC in one go!

ash_demon8: 2018-04-05 18:13:27

AC in one go...... with 4 lines of code:)

Added by:Muhammad Ridowan
Time limit:0.680s-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)