HDU 6052 To my boyfriend(概率 贡献)】的更多相关文章

说实话不是很懂按题解怎么写,思路来源于 http://blog.csdn.net/calabash_boy/article/details/76272704?yyue=a21bo.50862.201879 写起来倒是挺短的. /* HDU 6052 - To my boyfriend [ 分析,期望 ] | 2017 Multi-University Training Contest 2 题意: 给出一个N*M的数字矩阵 求子矩阵的不同数字的个数的期望 限制 N,M <= 100 分析: 统计单…
To my boyfriend Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1246    Accepted Submission(s): 556 Problem Description Dear LiaoI never forget the moment I met with you. You carefully asked me:…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6052 [题目大意] 给出一个数字矩阵,求子矩阵期望数字种数 [题解] 我们统计[x,y]为其所表示的数字的最左上方的矩形数量,即该格子的贡献值, 我们用悬线法将上边界上移,调整左右边界保证[x,y]为数字左上边界, 那么x及其以下的部分都可以作为下边界,顺序统计即可, 由于障碍点的顺序设置保证了二维的偏序性,不会出现重复统计贡献. [代码] #include <cstdio> #include…
题目 OvO click here http://acm.hdu.edu.cn/showproblem.php?pid=6052 (2017 Multi-University Training Contest - Team 2 - 1008) 解 分开考虑每种颜色 pre[i][j]代表第j列最近一个i颜色的行数,ppre是次近 calcu(li,ji,x,y,clr)表示从col=li到col=ri,计算(x,y)点对mp[x][y]=clr颜色有贡献的矩形的个数(其实并不是,准确说是(n-i…
题目链接 Problem Description Dear Liao I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you teach me?". I replied with a smile, "of course". You replied:"Given a matrix, I randoml…
题意:对于一个n*m的方格,每个格子中都包含一种颜色,求出任意一个矩形包含不同颜色的期望. 思路: 啊啊啊啊啊,补了两天,总算A了这道题了,简直石乐志,前面的容斥还比较好写,后面的那个>13那个最开始思路错了,然后 竟然只有一组样例没有过???? 然后以为是哪里写挂爆long long了.后来想了好久,明明思路完全就是错的! 最开始想的 是直接找那个值的外围的就好了, 忽略了里面的,然后其实问题是转化成在01矩阵中找全1矩阵的个数,本来兴冲冲的写了一发, 发现和正方形DP不是一个东西.... 感…
http://acm.split.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Problem Description   Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka save the world. But because of the plot of the Boss Incubator, she is t…
http://acm.hdu.edu.cn/showproblem.php?pid=3076 不可思议的题目,总之血量越少胜率越高,所以读取时把两人的血量交换一下 明显每一轮的胜率和负率都是固定的,所以设psc为胜率,pls为负率,peq为平率, 则在每一局中的胜率负率平率可以确定, 而在有结果的一个阶段中的胜率和负率则各是一个无穷级数 psc(new)=1*psc+peq*psc+peq*peq*psc.......=lim(n->正无穷)(1-peq^n)*psc/(1-peq)=psc/(…
ATM Mechine 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5781 Description Alice is going to take all her savings out of the ATM(Automatic Teller Machine). Alice forget how many deposit she has, and this strange ATM doesn't support query deposit. T…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. 算法思路:n个草莓在圆形上有一个最左边的,为了好理解,先把假设草莓有1-n的不同编号.  现在从n个草莓中选出一个编号A的放在最左边(这个最左边可以随便放),得到C(n,1)*1.然后把其余的n-1草莓不分先后的放在A的右边角大小为(360)/m的扇形区域内就可以了. 所以概率为 n/(m^(n-…