【Codeforces 105D】 Bag of mice】的更多相关文章

[题目链接] 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 -…
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…
[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…
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q个操作; 有以下两种类型 ①将第i个连通块里面灯取反 ②询问你(x1,y1)(x2,y2)这个矩形区域内灯的权值的和; [题解] 要用到二维的树状数组; 取反操作只要O(1)就能完成; 即先不管它是什么,取反就是了; 然后在询问的时候,直接用二维树状数组累加; 这里的累加可能是减也可能是加; 也可能…