【HDU-6362】解题报告(数学,积分,2018杭电多校第六场)
原始题目
oval-and-rectangle
- Time Limit: 2000/1000 MS (Java/Others)
- Memory Limit: 32768/32768 K (Java/Others)
- Total Submission(s): 647
- Accepted Submission(s): 310
Problem Description
Patrick Star find an oval.
The half of longer axes is on the x-axis with length \(a\).
The half of shorter axes is on the y-axis with length \(b\).
Patrick Star plan to choose a real number c randomly from \([0,b]\), after that, Patrick Star will get a rectangle :
The four vertexes of it are on the outline of the oval.
The two sides of it parallel to coordinate axis.
One of its side is \(y=c\).
Patrick Star want to know the expectations of the rectangle's perimeter.
Input
The first line contain a integer \(T\) (no morn than 10), the following is \(T\) test case, for each test case :
Each line contains contains two integer \(a, b (0<b<a<105)\). Separated by an white space.
Output
For each test case output one line denotes the expectations of the rectangle's perimeter .
You should keep exactly 6 decimal digits and ignore the remain decimal digits.
It is guaranted that the 7-th decimal digit of answer wont be 0 or 9.
Sample Input
1
2 1
Sample Output
8.283185
Source
2018 Multi-University Training Contest 6
Recommend
chendu
题目大意
- 椭圆半长轴为\(a\),半短轴为\(b\),从区间\([0,b]\)随机抽实数\(c\),求过\((0,c)\)点的与椭圆内切,四边与坐标轴平行 的长方形周长
解题思路
- 是个积分题,不过直接用积分函数计算到制定精度会T(没错我就这么T了一发)
- 手动算一下
- 最后除以b得到答案
- 注意要求不四舍五入,精度应该输出\(ans-0.0000005\)
解题代码
1 |
|
收获与反思
- 高数教做人系列
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!