ZOJ 3822 Domination 概率dp 难度:0】的更多相关文章

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar…
Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar…
题目链接 参考博客:http://blog.csdn.net/napoleon_acm/article/details/40020297 题意:给定n*m的空棋盘 每一次在上面选择一个空的位置放置一枚棋子,直至每一行每一列都至少有一个棋子,求放置次数的期望 分析: dp[i][j][k] 表示当前用了<=k个chess ,覆盖了i行j列(i*j的格子 每行至少一个,每列至少一个)的概率. dp[i][j][k] 由 dp[i][j][k-1] , dp[i-1][j][k-1], dp[i][j…
一个n行m列的棋盘,每天可以放一个棋子,问要使得棋盘的每行每列都至少有一个棋子 需要的放棋子天数的期望. dp[i][j][k]表示用了k天棋子共能占领棋盘的i行j列的概率. 他的放置策略是,每放一次,就会有四种可能 1)增加一行一列 2)增加一行 3)增加一列 4)不变 所以他放置的概率就可以求出来,每次放下的概率就是当前能放的点除以总的空的点数. 最后统计期望的时候需要统计在第k天刚好符合占满n行m列的概率,就是dp[i][j][k]-dp[i][j][k-1] #include <cstd…
题目链接:problemId=5376">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5376 Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative ch…
ZOJ Problem Set - 3822 Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a lar…
Domination Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3822 Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends.…
Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar…
Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place a chess piec…
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://acm.hdu.edu.cn/showproblem.php?pid=4405 明显,有飞机的时候不需要考虑骰子,一定是乘飞机更优 设E[i]为分数为i时还需要走的步数期望,j为某个可能投出的点数如果从i向i-j推导,我们并不能确定i的转移方向,因为可能有两个i-j有飞机其目的地是i,所以我们选择从i向i+j推导期望 如果设G[i]为分数为i时已经走过的步数期望,那么要确定G[i+j]需要知道P(i|i+j),也即转移到i+j的条件下从i转移来的概率,比较麻烦 由题意,设match…
题目链接:zoj 3822 Domination 题目大意:给定一个N∗M的棋盘,每次任选一个位置放置一枚棋子,直到每行每列上都至少有一枚棋子,问放置棋子个数的期望. 解题思路:大白书上概率那一张有一道类似的题目,可是由于时间比較久了,还是略微想了一下. dp[i][j][k]表示i行j列上均有至少一枚棋子,而且消耗k步的概率(k≤i∗j),由于放置在i+1~n上等价与放在i+1行上,同理列也是如此.所以有转移方程: dp[i][j][k+1]+=dp[i][j][k]∗(n−k)(S−k) d…
E - Domination Time Limit:8000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Status Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he…
Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar…
///dp[i][j][k]代表i行j列件,并把一k的概率 ///dp[i][j][k]一种常见的方法有四种传输 ///1:dp[i-1][j][k-1] 可能 (n-(i-1))*j/(n*m-(k-1)) ///2:dp[i][j-1][k-1] 概率为 i*(m-(j-1))/(n*m-(k-1)) ///3:dp[i-1][j-1][k-1] 概率为 (n-(i-1))*(m-(j-1))/(n*m-(k-1)) ///4:dp[i][j][k-1] 概率为 (i*j-(k-1))/(n…
解题报告链接: http://www.cnblogs.com/183zyz/archive/2012/09/13/2683524.html 做法:设当有i个吸血鬼时变成n个吸血鬼的天数的数学期望为dp[i]. pi为人和吸血鬼相遇的概率,pi = i*(n-i)/cn2 . cn2表示从n个人中选两个人出来的选法,那么人和吸血鬼相遇的选法为i*(n-i).p为人变吸血鬼的概率. 则有dp[i] = p*pi*(dp[i+1]+1)+(1-p*pi)(dp[i+1]+1) 化为:dp[i] = d…
3799567 2014-10-14 10:13:59                                                                     Accepted                                                             3822 C++ 1870 71760 njczy2010 3799566 2014-10-14 10:13:25                            …
题意: 给N×M的棋盘.每天随机找一个没放过棋子的格子放一个棋子 问使得每一个每列都有棋子的天数期望 思路: dp[i][j][k] 代表放了i个棋子占了j行k列 到达目标状态的期望 然后从 dp[n*m][n][m] 往后递推就好了. 由于知道了有i个棋子 比如一个状态dp[6][3][3] x x x o o o x o o o o o x o x o o o o o o o o o 对于 dp[i+1][3][3] 事实上就是3*3剩下的空再放一个,概率就是(j*k-i) / (n*m-i…
Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place…
http://acm.hdu.edu.cn/showproblem.php?pid=4089 这道题中一共有两个循环: 1.事件1 如果一直落在Activation failed事件上,那么就会重新继续直到出现事件2,3,或4为止, 这样 进入事件2的概率是p2'=p2+p2*p1+p2*p1*p1........解这个无穷级数得到p2'=p2/(1-p1),同理,p3'=p3/(1-p1),p4=p4/(1-p1) 2.事件2 设dp[i][j]为队列长度为i,主角在j时满足条件的概率,则 当…
题意: 给你三个均匀k面筛子. 分别有k1 k2 k3个面,每个面朝上的概率是相等的. 如果第一个筛子出现a第二个筛子出现b第三个筛子出现c那么置零. 否则在当前和加上三个点数之和. 求当前和大于n需要的步数的期望. 思路: 一开始状态转移搞错了,手推公式交了WA,后来想了想状态转移的过程发现每个状态都跟0状态有关系,但是dp[0]不确定,但是幸运的是这是一个线性变换,所以状态转移的时候记录一下dp[0]的系数,最后移项输出就好了. dp[i]=dp[i+x]*(k1*k2*k3);(x=i+j…
题意: 一个棋盘假设每行每列都有棋子那么这个棋盘达到目标状态  如今随机放棋子  问达到目标状态的期望步数 思路: 用概率来做  计算第k步达到目标状态的概率  进而求期望  概率计算方法就是dp  dp[k][i][j]表示第k步有i行被覆盖j列被覆盖  转移仅仅有4种  -- 同一时候覆盖行列  覆盖行  覆盖列  不覆盖  状态数50^4  非常easy 代码: #include<cstdio> #include<iostream> #include<cstring&g…
一个n行m列的棋盘,每次能够放一个棋子.问要使得棋盘的每行每列都至少有一个棋子 须要的放棋子次数的期望. dp[i][j][k]表示用了k个棋子共能占据棋盘的i行j列的概率. 那么对于每一颗棋子,在现有的棋盘上,它可能有四种影响:新占了一行,新占了一列,既占了新的一行又占了新的一列.无影响. 对于每一种情况.dp[i][j][k]=原始状态的概率×选到这种位置的概率 最后算答案的时候注意到,题目问的是到第k个刚好放完n行m列.也就是最后一个棋子一定是有作用的, 所以用dp[i][j][k]-dp…
http://acm.hdu.edu.cn/showproblem.php?pid=4050 题意: 现在主角站在0处,需要到达大于n的位置 主角要进入的格子有三种状态: 0. 不能进入 1. 能进入左脚,下一步出右脚 2. 能进入右脚,下一步出左脚 3. 两只脚都能进入,而且下一步迈出左右脚都可. 也就是说,如果只有1,2种状态的格子,那么主角只能重复左脚-右脚-左脚...或者右脚-左脚-右脚 但是有了状态为3的格子,就能够左脚-左脚-左脚这样走路 设e[i][sta]为主角在编号为i的方格状…
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4530 dp[i]表示现在存在i个吸血鬼要达成目标(全为吸血鬼)天数的数学期望假如现在再增加一天,这一天可能会增加一个吸血鬼,p1*(dp[i+1]+1)表示接下来的一天增加了一个吸血鬼,所以为(dp[i+1]+1),还有一种可能就是没有增加吸血鬼,概率自然是(1-p1)dp[i]+1表示接下来的一天没有增加吸血鬼,但向后推移了一天因此dp[i]这个状态可以转移到dp[i…
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1903 题意 一棵树,根上有VOD站,要求任意叶节点到VOD站的距离不超过k,问最少建新VOD站数. 思路 1. 令vod[i]为节点i到VOD站的最短距离,  注意,这是在以i为根的树上有VOD站的情况下,如果没有,vod[i]就设为非法. 依据树形DP的思路,如果在该…
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least a…
143. Long Live the Queen time limit per test: 0.25 sec. memory limit per test: 4096 KB The Queen of Byteland is very loved by her people. In order to show her their love, the Bytelanders have decided to conquer a new country which will be named accor…
http://acm.timus.ru/problem.aspx?space=1&num=1203 按照结束时间为主,开始时间为辅排序,那么对于任意结束时间t,在此之前结束的任务都已经被处理,从这个时间开始的任务都正要被处理, 因为t<=3e5,可以用简单dp解决 #include <cstdio> #include <algorithm> using namespace std; const int maxn=1e5+5; int n; typedef pair&l…
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3551 题意:开始有N-1个人和一个吸血鬼, 每天有两个生物见面,当人遇到吸血鬼时有p的概率变成吸血鬼,求全部变成吸血鬼所需要的时间的期望~ 思路: 设dp[i] 为还有 i 个人时,有一人变成吸血鬼的期望时间, p[i]为还有 i 个人时,有人变成吸血鬼的概率, 那么p[i]= p*i(N-i)/(N*(N-1)/2)~  dp[i]=1/p[i]; 由 E(X)=…