#include <stdio.h>
#include <math.h>
#define PRECISION 1e-10
double PI = acos(-1.0);
int bookshelfHeight, bookHeight, bookshelfLength;
//agnle是书本和书架的夹角
double calculateResult(double angle){
return bookHeight * cos(angle) * 0.5 - bookshelfHeight / tan(angle);
}
int main(){
scanf("%d%d%d", &bookshelfHeight, &bookHeight, &bookshelfLength);
double minAngle = 0.0;
double maxAngle = PI * 0.5;
while (maxAngle - minAngle > PRECISION){
double leftMidAngle = (minAngle + maxAngle) * 0.5;
double rightMidAngle = (leftMidAngle + maxAngle) * 0.5;
if (calculateResult(leftMidAngle) > calculateResult(rightMidAngle))
maxAngle = rightMidAngle;
else
minAngle = leftMidAngle;
}
double result = calculateResult((minAngle + maxAngle) * 0.5);
printf("%.6lf\n", result);
return 0;
}
07-20
1047
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交