• FZU Problem 2132 LQX的作业 (数学题)


    http://acm.fzu.edu.cn/problem.php?pid=2132

    N个数已经排成非递减顺序,那么每次可以取 前m->n个在x前面.
    取前m个在x前面的概率是 C(n,m)*x^m*(1-x)^(n-m)
    依次递推即可.

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cmath>
     4 #include <vector>
     5 #include <cstring>
     6 #include <string>
     7 #include <algorithm>
     8 #include <string>
     9 #include <set>
    10 #include <functional>
    11 #include <numeric>
    12 #include <sstream>
    13 #include <stack>
    14 #include <map>
    15 #include <queue>
    16 //#pragma comment(linker, "/STACK:102400000,102400000")
    17 #define CL(arr, val)    memset(arr, val, sizeof(arr))
    18 
    19 #define ll long long
    20 #define inf 0x7f7f7f7f
    21 #define lc l,m,rt<<1
    22 #define rc m + 1,r,rt<<1|1
    23 #define pi acos(-1.0)
    24 
    25 #define L(x)    (x) << 1
    26 #define R(x)    (x) << 1 | 1
    27 #define MID(l, r)   (l + r) >> 1
    28 #define Min(x, y)   (x) < (y) ? (x) : (y)
    29 #define Max(x, y)   (x) < (y) ? (y) : (x)
    30 #define E(x)        (1 << (x))
    31 #define iabs(x)     (x) < 0 ? -(x) : (x)
    32 #define OUT(x)  printf("%I64d
    ", x)
    33 #define lowbit(x)   (x)&(-x)
    34 #define Read()  freopen("a.txt", "r", stdin)
    35 #define Write() freopen("b.txt", "w", stdout);
    36 #define maxn 1010
    37 #define maxv 1010
    38 #define mod 1000000000
    39 using namespace std;
    40 
    41 double solve(int n,int m)
    42 {
    43     double ans=1;
    44     for(int i=n;i>m;i--)
    45         ans*=i;
    46     for(int i=1;i<=n-m;i++)
    47         ans/=i;
    48     return ans;
    49 }
    50 
    51 int main()
    52 {
    53    // Read();
    54     int t,n,m;
    55     double x,ans;
    56     scanf("%d",&t);
    57     while(t--)
    58     {
    59         scanf("%d%d%lf",&n,&m,&x);
    60         ans=0;
    61         for(int i=m;i<=n;i++)
    62         {
    63             ans+=solve(n,i)*pow(x,i)*pow((1-x),(n-i));
    64             //printf("%.4lf %.4lf
    ",pow(x,i),pow(1-x,n-i));
    65         }
    66         printf("%.4lf
    ",ans);
    67     }
    68     return 0;
    69 }
  • 相关阅读:
    21天搞定聊天机器人之{命名实体识别}
    e到底是什么?
    An example of using Pandas for regression
    Time-Series Analysis
    Multiple Regression
    Regression Analysis Using Excel
    Correlation and Regression
    Hypothesis Testing
    Sampling and Estimation
    Common Probability Distributions
  • 原文地址:https://www.cnblogs.com/nowandforever/p/4569977.html
Copyright © 2020-2023  润新知