• fzu 2132 LQX的作业


    Problem 2132 LQX的作业

    Accept: 67    Submit: 150
    Time Limit: 1000 mSec    Memory Limit : 32768 KB

    Problem Description

    LQX在做作业时遇到一个难题不会做,请你帮她计算一下:在N个独立地分布于0和1之间的随机变量排为非递减顺序之后,这些变量中第M个小于等于x的概率是多少?

    Input

    第一行一个整数T(T<=1000),表示有T组数据。

    每组数据一行,依次是N M x(1<=M<=N<30, 0<x<1),以空格隔开。

    Output

    每组数据对应一行输出,即概率是多少,四舍五入保留4位小数。

    Sample Input

    3
    1 1 0.3
    2 1 0.5
    2 2 0.8

    Sample Output

    0.3000
    0.7500
    0.6400
     
     "在N个独立地分布于0和1之间的随机变量排为非递减顺序之后,这些变量中第M个小于等于x的概率是多少?",  
      相当于至少有M个的概率。
     1 #include<iostream>
     2 #include<stdio.h>
     3 #include<cstring>
     4 #include<cstdlib>
     5 using namespace std;
     6 typedef __int64 LL;
     7 
     8 LL cnm[52][52];
     9 void prepare()
    10 {
    11     LL i,j;
    12     for(i=0;i<=50;i++)
    13     {
    14         cnm[i][0]=1;
    15         cnm[0][i]=1;
    16     }
    17     for(i=1;i<=50;i++)
    18         for(j=1;j<=i;j++)
    19         {
    20             if(i==j) { cnm[i][j]=1;continue;}
    21             if(j==1) { cnm[i][j]=i;continue;}
    22             cnm[i][j]=cnm[i-1][j]+cnm[i-1][j-1];
    23         }
    24 }
    25 int main()
    26 {
    27     LL n,m,T;
    28     LL i,j;
    29     double x,cur,hxl;
    30     prepare();
    31     scanf("%I64d",&T);
    32     while(T--)
    33     {
    34         scanf("%I64d%I64d%lf",&n,&m,&x);
    35         cur=0;
    36         for(i=m;i<=n;i++)
    37         {
    38             for(hxl=1,j=1;j<=n;j++)
    39             {
    40                 if(j<=i)
    41                     hxl=hxl*x;
    42                 else hxl=hxl*(1-x);
    43             }
    44             cur=cur+cnm[n][i]*hxl;
    45         }
    46         printf("%.4lf
    ",cur);
    47     }
    48     return 0;
    49 }
  • 相关阅读:
    Auto Generate Reflection Information for C++
    面向嵌入式的JavaScript引擎
    如何在unity3d的UGUI中给Text添加材质和艺术字
    获取Unity GLES版本
    PBR原理
    Unity双开
    Unity Shader各种效果
    Redis是什么
    其他地方拷贝过来的VS项目一直报错不能启动IIS
    IIS部署PHP项目并与mysql完美结合
  • 原文地址:https://www.cnblogs.com/tom987690183/p/3615661.html
Copyright © 2020-2023  润新知