[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\n",dp[n][n]);
    }
    return 0;
}
				
时间: 2024-11-10 14:15:56

[ahu 1248] NBA Finals的相关文章

SWUST OJ NBA Finals(0649)

NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128 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

swust oj 649--NBA Finals(dp,后台略(hen)坑)

题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 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

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

linux用户管理命令之NBA版

用户管理命令之NBA版 本文纯属扯淡,如有不严谨之处,还请海涵. 1 groupadd 作用:创建一个属组 格式:groupadd [选项] 属组名 选项:     -:选项为空 创建新属组,    -g:指定组GID,默认是GID+1 实例 1.1 添加属组team,指定组ID为1111     groupadd -g 1111 team 2 groupmod 作用:修改属组信息 格式:groupmod [选项] 属组名 选项:     -g:GID 修改属组GID -n:修改属组名 实例 2

大数据之NBA

2017年NBA季后赛落幕后,网络上仍有大量关于NBA关键词的搜索. 这是近30天来,通过PC端和移动端搜索的趋势,可以看到有些日期的搜索指数是猛增的,因为NBA有大新闻爆出,比如8月23日,骑士与凯尔特人正式达成交易,小托马斯与欧文互换东家. 下面是8月份的搜索需求图谱. 下面是暑假期间的关于NBA搜索的地域分布,广东的搜索量全国第一. 下面是对NBA感兴趣的人群属性,女性只占极少数,而20至50岁的男性是NBA观众的主力军.

[Codeforces 625D]Finals in arithmetic

题目链接:625D - Finals in arithmetic 这道题是Special Judge.开始是aynuzzh让我去做的.题目大意是定义a翻转后为ar,例如当a=123时,ar=321.给出一个数n(1≤n≤10100 000),求a满足a+ar=n.答案可能有很多,输出其中的一个即可. 我们先来看,假如有一个数每一位为a,b,c,d,那么翻转之后就是d,c,b,a,相加的结果是a+d,b+c,c+b,d+a,是一个回文数.那么我们就要将n分解成一个回文的数列来求a.我们知道a的每一

错误代码: 1248 Every derived table must have its own alias

1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT stu_id, (SELECT stu_name FROM t_student_info t WHERE t.stu_id = t.stu_id) stu_name FROM (SELECT SUM( CASE course WHEN '敮.. 错误代码: 1248 Every derived table must have its own alias 执行耗