zoukankan      html  css  js  c++  java
  • [ahu 1248] NBA Finals

    NBA Finals
    Time Limit: 1000 ms   Case Time Limit: 1000 ms   Memory Limit: 64 MB
    Total Submission: 251   Submission Accepted: 41
     
    Description
    Consider two teams, Lakers and Celtics, playing a series of NBA Finals until one of the teams wins n games. Assume that the probability of Lakers winning a game is the same for each game and equal to p and the probability of Lakers losing a game is q = 1-p. Hence, there are no ties.Please find the probability of Lakers winning the NBA Finals if the probability of it winning a game is p.
    Input
    1st line: the game number (7<=n<=165) the winner played. 
    2nd line: the probability of Lakers winning a game p (0<p<1).
    Output
    1st line: The probability of Lakers winning the NBA Finals.
    Round the result to 6 digits after the decimal point and keep trailing zeros.
    Sample Input

    7
    0.4

    Sample Output

    0.22884

    4

    概率DP

    一样的题、swustoj 649

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    using namespace std;
    #define N 210
    
    int main()
    {
        int n;
        double p;
        double dp[N][N];
        while(scanf("%d%lf",&n,&p)!=EOF)
        {
            memset(dp,0,sizeof(dp));
            for(int i=0;i<=n;i++) dp[0][i]=1;
            for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++){
                    dp[i][j]=dp[i-1][j]*p+dp[i][j-1]*(1-p);
                }
            }
            printf("%.6f
    ",dp[n][n]);
        }
        return 0;
    }
    
    
  • 相关阅读:
    python 读execl文件
    git 命令 个人备忘录
    python-django后端,富文本编辑器防XSS漏洞攻击,过滤富文本XSS
    mi
    Glance docker安装 cinder
    keystore glance
    openstack管理docker管理
    lvm 磁盘 数据库 wordpress 参考答案
    docker
    wordpress
  • 原文地址:https://www.cnblogs.com/hate13/p/4562670.html
Copyright © 2011-2022 走看看