Do not pour out HDU - 5954 數學積分

來源:互聯網
上載者:User

標籤:turn   ios   names   參考   blank   stream   int   str   pac   

題目:題目連結

思路:純高等數學問題,不過不是很好積分,具體積分思路及過程參考大佬部落格——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\n");31         else if(h >= 1.0) {32             double a = atan(2.0 - h);33             printf("%.5f\n", 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                 else42                     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\n", s);48         }49     }50     return 0;51 }

 

Do not pour out HDU - 5954 數學積分

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.