标签:des style http os io ar strong for sp
Description
Time Limit: 1 sec
Memory Limit: 16MB
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 is from interval [-a;a]; y is from interval [-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?
%
" symbol following that number on a single line. P must be rounded to 6 digits after decimal point.
3 10 5 20 1 1 1 2 2 0
23.348371% 0.000000% 100.000000% 题意:给定a,b,s要求在[-a,a]选定x,在[-b,b]选定y,使得(0, 0)和(x, y)组成的矩形面积大于s的概率 思路:转换成x*y > s的图形面积,利用求导函数求面积的方式计算,y=s/x的导函数是y=s*lnx
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; int main() { int t; double a, b, s; scanf("%d", &t); while (t--) { scanf("%lf%lf%lf", &a, &b, &s); if (a * b <= s) { puts("0.000000%"); continue; } if (s == 0) { puts("100.000000%"); continue; } printf("%lf%%\n", 100 - (s + s * (log(a) - log(s / b))) / a / b * 100); } return 0; }
标签:des style http os io ar strong for sp
原文地址:http://blog.csdn.net/u011345136/article/details/39084139