【codeforces 148D】 Bag of mice】的更多相关文章

http://codeforces.com/problemset/problem/148/D (题目链接) 题意 包中有w个白鼠,b个黑鼠.公主和龙轮流画老鼠,公主先画,谁先画到白鼠谁就赢.龙每画完一只老鼠,就会有另一只老鼠从包中跑出来.每只老鼠被画到以及跑出的概率相等,问公主获胜的概率. Solution 令${f_{0/1,i,j}}$表示此时公主/龙选,包中还剩i只白鼠,j只黑鼠,公主赢的概率.那么转移很显然: $${f_{0,i,j}=\frac{i}{i+j}+\frac{j}{i+j…
[题目链接] http://codeforces.com/contest/148/problem/D [算法] 概率DP f[w][b]表示还剩w只白老鼠,b只黑老鼠,公主胜利的概率,那么 : 1. 公主抓到白老鼠,概率为w/(w+b) 2. 公主抓到黑老鼠,那么龙也抓到黑老鼠,如果跑出来的老鼠是白颜色的,则概率为 : b / (w + b) * b / (w + b - 1) * w / (w + b - 2) * f[w-1][b-2] 否则,概率为 : b / (w + b) * (b -…
概率DP kuangbin总结中的第9题 啊……题目给的数据只有白鼠和黑鼠的数量,所以我们只能在这个上面做(gao)文(D)章(P)了…… 明显可以用两种老鼠的数量来作为状态= = 我的WA做法: 令f[i][j]表示从(w,b)轮流取老鼠一直到(i,j)[此时轮process取]两人一直不分胜负的概率,很明显(i,j)这个状态下赢的概率为 i / (i+j) ,那么总共赢的概率就是对所有(i,j),f[i][j]*i/(i+j)求和 转移当然很简单啦~ f[i][j]只可能从f[i][j+3]…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains t…
[题目链接]:http://codeforces.com/contest/793/problem/C [题意] 给你每个点x轴移动速度,y轴移动速度; 问你有没有某个时刻,所有的点都"严格"在所给的矩形内 [题解] 把二维的问题转化成一维的问题; 那样问题就转换成 x1..x2是目标的线段(一维的) 然后有若干个xi 问你从xi变化到到x1..x2这个区间最短和最长时间(分别对应第一次进入这个区间和出这个区间的时间); yi同理; 然后求时间的交集就可以了; 对于都刚好在边框上的情况;…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Just to remind, girls in Arpa's land are really nice. Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some wei…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same colo…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags,…
D. Bag of mice http://codeforces.com/problemset/problem/148/D time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The dragon and the princess are arguing about what to do on the New Year's Eve…