题目:题目链接
思路:纯高等数学问题,不过不是很好积分,具体积分思路及过程参考大佬博客——https://blog.csdn.net/danliwoo/article/details/53002695
AC代码:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 #include <iomanip> 6 7 using namespace std; 8 9 #define pi acos(-1.0) 10 11 double h; 12 13 double cal(double a) { 14 return pi * cos(a) - a * cos(a) + sin(a) - pow(sin(a), 3) / 3; 15 } 16 17 double calV(double b) { 18 double a = acos(2 * tan(b) - 1.0); 19 return (cal(a) - cal(pi)) / tan(b); 20 } 21 22 int main() 23 { 24 int T; 25 scanf("%d", &T); 26 while(T--) { 27 scanf("%lf", &h); 28 double v = pi * h; 29 if(h < 1e-10) 30 printf("0.00000 "); 31 else if(h >= 1.0) { 32 double a = atan(2.0 - h); 33 printf("%.5f ", pi / cos(a)); 34 } 35 else { 36 double l = 0, r = pi / 4; 37 while(r - l > 1e-9) { 38 double m = (l + r) / 2; 39 if(calV(m) < v) 40 l = m; 41 else 42 r = m; 43 } 44 double x = 2 * tan(r); 45 double a = acos(x - 1); 46 double s = (pi - a + sin(a) * cos(a)) / sin(r); 47 printf("%.5f ", s); 48 } 49 } 50 return 0; 51 }