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,,sizeof(dp));
for(int i=;i<=n;i++) dp[][i]=;
for(int i=;i<=n;i++){
for(int j=;j<=n;j++){
dp[i][j]=dp[i-][j]*p+dp[i][j-]*(-p);
}
}
printf("%.6f\n",dp[n][n]);
}
return ;
}

[ahu 1248] NBA Finals的更多相关文章

  1. SWUST OJ NBA Finals(0649)

    NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128   Descri ...

  2. [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)

    题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...

  3. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

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

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

  5. 寒冰王座 hdu 1248(背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=1248 #include <stdio.h> #include <stdlib.h> #i ...

  6. 见证历史 -- 2013 NBA 热火夺冠之路有感

    见证历史-- 2013 NBA 热火夺冠之路有感今年NBA季后赛从第一轮看起,到最终的热火夺冠,应该看得是最爽的一次.但一些情节和细节,回忆起来,深有感悟. 1. 做人要低调詹宁斯豪言演黑八雄鹿本赛季 ...

  7. JavaScript案例六:简单省市联动(NBA版)

    JavaScript实现简单省市(NBA版)联动 <!DOCTYPE html> <html> <head> <title>JavaScript实现简单 ...

  8. ACM - ICPC World Finals 2013 F Low Power

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 问题描述 有n个机器,每个机器有2个芯片,每个 ...

  9. Codeforces Round #342 (Div. 2) D. Finals in arithmetic 贪心

    D. Finals in arithmetic 题目连接: http://www.codeforces.com/contest/625/problem/D Description Vitya is s ...

随机推荐

  1. C++ 编写 CorelDRAW CPG 插件例子(2)—ClearFill

    这是另一个例子: 贴上主要代码: #include "stdafx.h" #include <tchar.h> #import "libid:95E23C91 ...

  2. Linux tar 解压缩命令

    tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个 ...

  3. 题目1444:More is better

    时间限制:3 秒 内存限制:100 兆 特殊判题:否 提交:1362 解决:640 题目描述: Mr Wang wants some boys to help him with a project. ...

  4. Java学习之路:1、HelloWorld

    似乎每种语言都是从HelloWorld开始的,所以,我的第一个java程序,也应该是这样开始的! 1.配置好jdk后,开始编写HelloWorld.java package second;//这个应该 ...

  5. 模式对话框里的CheckedChanged事件

    问题:   模式对话框里的CheckedChanged事件不被触发: 解决方法: 一.先不直接showModalDialog出要的页面,而是要放一个中单页面 window.showModalDialo ...

  6. ViewData,ViewBag和TempData

      ViewData ViewBag TempData 类型 字典 Dynamic TempDataDictionary 出生时间 MVC1 MVC3   框架版本 .net3.5 .net4.0   ...

  7. ExtJS4.2学习(六)表格分页与通过后台脚本获得分页数据

    鸣谢:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2013-11-12/175.html --------------- ...

  8. js常识

    btnDelAll.Attributes.Add("onclick", "<script lunguage='javascript'>return windo ...

  9. 【数学】[BZOJ 3884] 上帝与集合的正确用法

    Description 根据一些书上的记载,上帝的一次失败的创世经历是这样的: 第一天, 上帝创造了一个世界的基本元素,称做“元”. 第二天, 上帝创造了一个新的元素,称作“α”.“α”被定义为“元” ...

  10. centos64位安装32位C/c++库

    yum install glibc.i686 glibc-devel.i686 yum install libstdc++.i686yum install libstdc++-devel.i686yu ...