uva 11346 Probability
2016-03-08 19:29
344 查看
原题:
Consider rectangular coordinate system and point L(X, Y ) which is randomly chosen among all points in the area A which is defined in the following manner: A = {(x, y)|x ∈ [−a; a]; y ∈ [−b; b]}. What is the probability P that the area of a rectangle that is defined by points (0,0) and (X, Y ) will be greater than S?
Input
The number of tests N ≤ 200 is given on the first line of input. Then N lines with one test case on
each line follow. The test consists of 3 real numbers a > 0, b > 0 ir S ≥ 0.
Output
For each test case you should output one number P and percentage ‘%’ symbol following that number
on a single line. P must be rounded to 6 digits after decimal point.
Sample Input
3
10 5 20
1 1 1
2 2 0
Sample Output
23.348371%
0.000000%
100.000000%
大意:
给你三个值,a,b,s。其中a,b,s>=0,告诉你在坐标系上以a,b和0,0为对角线所形成矩形的面积大于s的概率。
解答:
上过高中的应该都会这道题。先计算出面积等于s的轨迹方程,就是y=s/x。然后求在在a和b所划定范围内中在轨迹方程上面的点即可。
Consider rectangular coordinate system and point L(X, Y ) which is randomly chosen among all points in the area A which is defined in the following manner: A = {(x, y)|x ∈ [−a; a]; y ∈ [−b; b]}. What is the probability P that the area of a rectangle that is defined by points (0,0) and (X, Y ) will be greater than S?
Input
The number of tests N ≤ 200 is given on the first line of input. Then N lines with one test case on
each line follow. The test consists of 3 real numbers a > 0, b > 0 ir S ≥ 0.
Output
For each test case you should output one number P and percentage ‘%’ symbol following that number
on a single line. P must be rounded to 6 digits after decimal point.
Sample Input
3
10 5 20
1 1 1
2 2 0
Sample Output
23.348371%
0.000000%
100.000000%
大意:
给你三个值,a,b,s。其中a,b,s>=0,告诉你在坐标系上以a,b和0,0为对角线所形成矩形的面积大于s的概率。
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int t; double a,b,s; cin>>t; while(t--) { cin>>a>>b>>s; if(b>a) swap(a,b); if(s==0) { cout<<"100.000000%"<<endl; continue; } if(b-s/a<=0) { cout<<"0.000000%"<<endl; continue; } double ans=(a*b-s+s*log(s/(a*b)))/(a*b); cout<<fixed<<setprecision(6)<<ans*100<<'%'<<endl; } return 0; }
解答:
上过高中的应该都会这道题。先计算出面积等于s的轨迹方程,就是y=s/x。然后求在在a和b所划定范围内中在轨迹方程上面的点即可。
相关文章推荐
- EXTJS 中 radiogroup 的各项所占的宽度不同的解决办法
- 就拿胖子说事2
- 第1周项目1 —宣告“主权”
- [Audio processing] 数据集生成 & 性别年龄分类训练 Python
- zoj3875 Lunch Time(水,但有意思)
- ZOJ 3919 Ellipse(数学)
- 移动平台游戏网络重连方案
- 第二周项目:就拿胖子说事
- SpringMVC入门示例(二)
- 简单浅谈 电鱼机的脉宽、频率、占空比
- Codeforces--630E--A rectangle(规律)
- 关于Microsoft Project默认开始时间错误问题
- 禁止U盘自动弹出
- C#中StreamReader读取中文出现乱码
- sonarqube分析实例工程
- bzoj 1189(拆点最大流)
- 联合体和结构体
- CSS之Win8界面摸拟
- Codeforces--630E--A rectangle(规律)
- Codeforces 630F - Selection of Personnel