概率论
题目:
Patrick Star find an oval.
The half of longer axes is on the x-axis with length aa.
The half of shorter axes is on the y-axis with length bb.
Patrick Star plan to choose a real number cc randomly from [0,b][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=cy=c.
Patrick Star want to know the expectations of the rectangle’s perimeter.
Input
The first line contain a integer TT (no morn than 10), the following is TT test case, for each test case :
Each line contains contains two integer a, b (0<b<a<1050<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
题意:椭圆里建立矩形,高等数学解一下。。
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iostream>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define ll long long
using namespace std;
int main()
{
int n,d,t;
double s1,s2,a,b,dis[100],len[100],v[100],z;
int cnt=1;double tt=0.0000005;
cin>>t;//cout<<fixed<<setprecision(6)<<acos(-1)<<endl;
//s1=3;s2=2;cout<<s2/s1;
while(t--){
cin>>a>>b;
s1=2*b+a*acos(-1);
cout<<fixed<<setprecision(6)<<s1-tt<<endl;
}
return 0;
}