水題日記

來源:互聯網
上載者:User

標籤:style   blog   color   os   io   div   log   ef   

一定要相信水題真的很水

POJ-2546

 1 #include<iostream> 2 #include<stdio.h> 3 #include<cmath> 4  5 using namespace std; 6  7 #define PI acos(double(-1)) 8  9 int main()10 {11     double x1, y1, r1, x2, y2, r2;12     cin>>x1>>y1>>r1>>x2>>y2>>r2;13     double l = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));14     double r = r1>r2? r2:r1;15     if(l<=abs(r1-r2))16         printf("%.3lf\n",r*r*PI);17     else if(l>=r1+r2)18         printf("%.3lf\n",0);19     else20     {21         double ang1 = acos((r1*r1+l*l-r2*r2)/(2*r1*l));22         double ss1 = r1*r1*ang1;23         double ang2 = acos((r2*r2+l*l-r1*r1)/(2*r2*l));24         double ss2 = r2*r2*ang2;25         double s1 = ss1 - r1*sin(ang1)*l/2;26         double s2 = ss2 - r2*sin(ang2)*l/2;27         printf("%.3lf",s1+s2);28     }29     return 0;30 }

單純的靠高中數學就切掉了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.