B Bowling Game
Topic links: https://ac.nowcoder.com/acm/contest/912/B
topic
CUST players after the game finished province, with a small r we go bowling.
Bowling is a very high degree of difficulty of the game, but this is simply difficult to live school team members, they all are very powerful (
fried and
) out of 10 bottles are inverted. Especially small r, eyes closed once every time to throw down 10 bottles. Among them there is not so much a sewer players, every time the ball thrown into the sewers, causing a ball not hit the bottle are in.
Rounds down, we find back the ball less and less, and finally left a few numbers 9 ball. They do not like to lose 9-ball, because too light.
After you work for little sister, that: let's Songjiang bowling club technology is not so advanced, so the background is manually operated to retrieve the ball, the ball did not come back now, cause fewer ball is a ball stuck, dropped into sewer it could lead to this situation now.
School team members know are a few, they are at least per person fried and once, only one sewer players. . .
We learned that the background is a square box, about this time will be stuck Bowling, shown in blue area S 1
Entry
Input common line by s1, s2 two positive integers, S . 1 and S 2 is a drawing area to ensure S . 1 , S 2 ≤ 10 . 9 and graphical method)
Output
输出一行,即保龄球的直径 D。
你的答案与标准答案误差在±0.001范围以内都算正确。
样例
input
6 25
693 2853
output
2
21.586519
思路
将s1分为三个小三角形,两个直角边的边长之和就是sqrt(4*s1+s2),斜边边长就是sqrt(s2),列一元二次方程即可
#include<bits/stdc++.h> using namespace std; int main() { int s1,s2; while(cin>>s1>>s2) { double len=sqrt(s2+4*s1); double _1=(len+sqrt(len*len-8*s1))/2; double _2=(len-sqrt(len*len-8*s1))/2; double xie=sqrt(s2); double sum=xie+_1+_2; cout<<fixed<<setprecision(6)<<(4*s1)/sum<<endl; } return 0; }