A - oval-and-rectangle

题意:给出一个椭圆的a 和 b,在$[0, b]中随机选择c$ 使得四个顶点在椭圆上构成一个矩形,求矩形周长期望

思路:求出每种矩形的周长,除以b(积分)

2018 Multi-University Training Contest 6 Solution

 1 #include<bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const double PI = acos(-1.0);
 6 
 7 double a, b;
 8 
 9 void RUN()
10 {
11     int t;
12     scanf("%d", &t);
13     while (t--)
14     {
15         scanf("%lf %lf", &a, &b);
16         double ans = 2 * b + a * PI;
17         printf("%.6f\n", ans - 5e-7);
18     }
19 }
20 
21 int main()
22 {
23 #ifdef LOCAL_JUDGE
24     freopen("Text.txt", "r", stdin);
25 #endif // LOCAL_JUDGE
26 
27     RUN();
28 
29 #ifdef LOCAL_JUDGE
30     fclose(stdin);
31 #endif // LOCAL_JUDGE
32     return 0;
33 }
View Code

相关文章:

  • 2021-08-22
  • 2022-01-16
  • 2022-02-09
  • 2021-11-13
  • 2018-09-06
  • 2018-07-24
  • 2018-08-14
猜你喜欢
  • 2021-07-18
  • 2021-08-06
  • 2021-06-09
  • 2021-06-13
  • 2021-10-14
  • 2021-12-03
相关资源
相似解决方案