codeforces105d Bag of mice ——概率DP
Link:
http://codeforces.com/problemset/problem/148/D
Refer to:
http://www.cnblogs.com/kuangbin/archive/2012/10/04/2711184.html
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
][];
int main(void)
{
int w,b;
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
while (~scanf("%d%d",&w,&b))
{
;i<=w;++i);j<=b;++j)a[i][j]=;
;i<=b;++i) a[][i]=;
;j<=w;++j) a[j][]=;
;i<=w;++i)
{
;j<=b;++j)
{
a[i][j]+=(double)i/(i+j);
)
a[i][j]+=a[i][j-]*(double)j/(i+j)
*()/(i+j-)
*()/(i+j-);
)
a[i][j]+=a[i-][j-]*(double)j/(i+j)
*()/(i+j-)
*();
}
}
printf("%.9lf\n",a[w][b]);
}
;
}
这题很有意思。为什么自己想不出来?
codeforces105d Bag of mice ——概率DP的更多相关文章
- Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题
除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃 ...
- Codeforces Round #105 (Div. 2) D. Bag of mice 概率dp
题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemo ...
- CF 148D Bag of mice 概率dp 难度:0
D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Bag of mice(概率DP)
Bag of mice CodeForces - 148D The dragon and the princess are arguing about what to do on the New Y ...
- codeforce 148D. Bag of mice[概率dp]
D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- codeforces 148D Bag of mice(概率dp)
题意:给你w个白色小鼠和b个黑色小鼠,把他们放到袋子里,princess先取,dragon后取,princess取的时候从剩下的当当中任意取一个,dragon取得时候也是从剩下的时候任取一个,但是取完 ...
- Codeforces 148D Bag of mice 概率dp(水
题目链接:http://codeforces.com/problemset/problem/148/D 题意: 原来袋子里有w仅仅白鼠和b仅仅黑鼠 龙和王妃轮流从袋子里抓老鼠. 谁先抓到白色老师谁就赢 ...
- 抓老鼠 codeForce 148D - Bag of mice 概率DP
设dp[i][j]为有白老鼠i只,黑老鼠j只时轮到公主取时,公主赢的概率. 那么当i = 0 时,为0 当j = 0时,为1 公主可直接取出白老鼠一只赢的概率为i/(i+j) 公主取出了黑老鼠,龙必然 ...
- Codeforces Round #105 D. Bag of mice 概率dp
http://codeforces.com/contest/148/problem/D 题目意思是龙和公主轮流从袋子里抽老鼠.袋子里有白老师 W 仅仅.黑老师 D 仅仅.公主先抽,第一个抽出白老鼠的胜 ...
随机推荐
- 深入浅出设计模式——工厂方法模式(Factory Method)
介绍在简单工厂模式中,我们提到,工厂方法模式是简单工厂模式的一个延伸,它属于Gof23中设计模式的创建型设计模式.它解决的仍然是软件设计中与创建对象有关的问题.它可以更好的处理客户的需求变化. 引入我 ...
- 访问google.com
ping www.google.com 得到的IP来访问
- js中的fadeIn()
一.fadeIn()淡入,fadeOut()淡出 fadeIn()和fadeOut()括号里边跟执行的时间
- PHP 小方法之 随机生成几位字符串
if(! function_exists ('get_rand_string') ) { function get_rand_string($len=6,$format='ALL') { switch ...
- String和StringBuffer、StringBuilder的区别
目录: 1.String类的不可变性 2.用String的时候需要注意什么 3.String与StringBuilder的区别 4.StringBuilder和StringBuffer的区别 Stri ...
- 分方式缓存常用的一致性hash是什么原理
分方式缓存常用的一致性hash是什么原理 一致性hash是用来解决什么问题的?先看一个场景有n个cache服务器,一个对象object映射到哪个cache上呢?可以采用通用方法计算object的has ...
- DbInitializer.cs初始化过程中context.entityName.Add()遇到的类型不匹配错误
用Asp.Net Core+EF Core建立一个测试项目过程中,使用DbInitializaer.cs进行数据库表的初始化工作,当项目测试运行时执行到context.实体名.Add()时,提示错误信 ...
- Unity NGUI 2D场景添加按钮
比如说先添加一个sprite 在sprite加上NGUI的 UI Button 然后重点来了 加上Box Collider 2D(重点:2D 千万不要加 Box Collider) 将Box Col ...
- guava学习--FluentIterable
public class FluentIterableTest { public static void main(String[] args) { Man man1 = new Man(" ...
- BZOJ1996 [Hnoi2010]chorus 合唱队
很容易想到区间DP 然后发现这个区间只和圆序列的最后一个数有关,而原序列的最后一个数只可能是现在区间的头或者尾 令$f[i][j][0/1]$表示在区间$[i, j]$之间,原序列的最后一个数是当前区 ...