zoukankan      html  css  js  c++  java
  • UVA 11346

    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%

    题解:给你x,y,s,问说在x,y与x,y轴形成的矩形内选取一点,和x,y轴形成图形的面积大于s的概率。

    题解: 

           画个图是求个积分

          S = s* (ln(x1)- ln(x));

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <bitset>
    using namespace std ;
    typedef long long ll;
    
    const int N = 3000 + 5;
    
    
    int main () {
        int T;
        scanf("%d",&T);
        while(T--) {
                double x,y,s;
            scanf("%lf%lf%lf",&x,&y,&s);
            double x1 = min(x,s / y);
            double S = 0;
            if(s > 1e-9) S = x1 * y + s * (log(x) - log(x1));
            //cout<<S<<endl;
            double p = 1.0 - S / (x * y);
            p *= 100;
            printf("%.6f%%
    ", p);
        }
        return 0;
    }
    daima
  • 相关阅读:
    生产上第一使用线程池后的总结与反思
    20190407
    20190403
    Asp.net MVC中的ViewData与ViewBag
    easyui datagrid分页
    EF从数据库更新模型更新不到新表
    C语言 笔记(函数)
    python 写100~1000以内水仙花数
    python 求前n项阶乘的和
    python 写九九乘法表
  • 原文地址:https://www.cnblogs.com/zxhl/p/5131949.html
Copyright © 2011-2022 走看看