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;
    }
    
    
  • 相关阅读:
    201141 live the lie until the lie becomes your life
    my php & mysql FAQ
    suger日料财务
    python 应用thrift thrift的监控fb303
    cherryPy学习
    my linux FAQ
    Javascript无阻塞加载方法
    设计模式学习笔记之组合模式模式
    【转】cookie
    C# 多线程
  • 原文地址:https://www.cnblogs.com/hate13/p/4562670.html
Copyright © 2011-2022 走看看