CF912D Fishes 期望
题意翻译
Description
有一个长为nnn ,宽为mmm 的鱼缸,还有一个边长为rrr 的正方形渔网。你可以往鱼缸里放kkk 条鱼,问用渔网随机在浴缸里捞鱼的最大期望是多少。不懂什么是期望的自己去百度
Input
一行4个正整数代表n,m,r,kn, m, r, kn,m,r,k
Output
输出一个实数,表示最大期望
感谢@xunzhen 提供的翻译
题目描述
While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n×m n×m n×m , divided into cells of size 1×1 1×1 1×1 , inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!).
The gift bundle also includes a square scoop of size r×r r×r r×r , designed for fishing. If the lower-left corner of the scoop-net is located at cell (x,y) (x,y) (x,y) , all fishes inside the square (x,y)...(x+r−1,y+r−1) (x,y)...(x+r-1,y+r-1) (x,y)...(x+r−1,y+r−1) get caught. Note that the scoop-net should lie completely inside the pond when used.
Unfortunately, Sasha is not that skilled in fishing and hence throws the scoop randomly. In order to not frustrate Sasha, Misha decided to release k k k fishes into the empty pond in such a way that the expected value of the number of caught fishes is as high as possible. Help Misha! In other words, put k k k fishes in the pond into distinct cells in such a way that when the scoop-net is placed into a random position among (n−r+1)⋅(m−r+1) (n-r+1)·(m-r+1) (n−r+1)⋅(m−r+1) possible positions, the average number of caught fishes is as high as possible.
输入输出格式
输入格式:
The only line contains four integers n,m,r,k n,m,r,k n,m,r,k ( 1<=n,m<=105 1<=n,m<=10^{5} 1<=n,m<=105 , 1<=r<=min(n,m) 1<=r<=min(n,m) 1<=r<=min(n,m) , 1<=k<=min(n⋅m,105) 1<=k<=min(n·m,10^{5}) 1<=k<=min(n⋅m,105) ).
输出格式:
Print a single number — the maximum possible expected number of caught fishes.
You answer is considered correct, is its absolute or relative error does not exceed 10−9 10^{-9} 10−9 . Namely, let your answer be a a a , and the jury's answer be b b b . Your answer is considered correct, if .
输入输出样例
说明
In the first example you can put the fishes in cells (2,1) (2,1) (2,1) , (2,2) (2,2) (2,2) , (2,3) (2,3) (2,3) . In this case, for any of four possible positions of the scoop-net (highlighted with light green), the number of fishes inside is equal to two, and so is the expected value.
很容易想到的一种思路是在被正方形覆盖次数最多的地方放
有趣的水题 由期望的线性性质,全局期望 = 每个格子的期望之和 由于权值一样,我们优先选概率大的点就好了 用一些数据结构来维护就好了 复杂度$O(k \log n)$ #include <set ... D. Fishes time limit per test 1 second memory limit per test 256 megabytes input standard input outp ... 题目链接:http://codeforces.com/contest/912/problem/D 题目大意: 在一个\(n \times m\)的网格中放鱼(每个网格只能放一条鱼),用一个\(r \t ... While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of ... 题目链接 Fishes 题意 在一个$n*m$的矩阵中,随机选择一个$r * r$的区域覆盖. 一开始我们可以在这个$n*m$的矩阵中选择$k$个点标记为$1$. 我们要选择一个最佳的标记策略,使得 ... cf1009E:求到第i段期望和的比较困难,但是单独求每段的期望是比较容易的,所以单独对每段求和,然后累计总和 E[i]=1/2*a1+1/4*a2+...+1/2^(i-1)*ai-1+1/2^(i ... 3143: [Hnoi2013]游走 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2264 Solved: 987[Submit][Status] ... 这道题之前我写过一个巨逗比的写法(传送门:http://www.cnblogs.com/liu-runda/p/6220381.html) 当时的原因是这道题可以抽象出和"绿豆蛙的归宿&qu ... (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ... 静态方法 通过@staticmethod来定义,静态方法在类中,但在静态方法里访问不了类和实例中的属性,但静态方法需要类来调用 # -*- coding:utf-8 -*- __author__ = ... 10-09C#语言基础 第一课 一.新项目的建立:打开Visual studio2012,单击“文件→新建项目→模板isualC# Windows 控制台应用程序→确定”即可. 在新建的项目中,首 ... https://www.cnblogs.com/gszhl/archive/2009/04/23/1441753.html vb和dos批处理创建或生成快捷方式 首先说我现在用的一种,最有效的也是 ... Diag:Diagonal matrices and diagonals of a matrix Syntax X = diag(v,k) X = diag(v) v = diag(X,k) v = ... 9.Search是可以输入你要下载的包的名称,能够快速筛选出你要下载的包.那四个单选按钮是选择下边树的样式,默认就行,不用动.View默认是Category,建议改成full显示全部包再查,省的一些包 ... 链表是一种物理存储单元上非连续.非顺序的存储结构. 链表是由那几个部分组成的呢? 是由N个节点组成的 每一个节点分为两部分: 1.数据域 ... double myPower(double base, int exponent){ if(exponent==0) return 1; if(exponent==1) return base; if ... 一.常用命令: 1.ls 只列出文件名 (相当于dir,dir也可以使用) -A:列出所有文件,包含隐藏文件. -l:列表形式,包含文件的绝大部分属性. -R:递归显示. --help:此命令的帮助. ... 想要java中邮件发送和接收邮件,首先需要支持SMTP- pop/pop3/IMAP协议,发送的话还需要配置文件,来对程序提供相应的接口,只需要这两个文件,就可以实现邮件的接收发送, 协议为jar包封 ... Win7系统优化脚本 用了多年win7,用的过程中,发现了一些问题,关于系统基本的优化,和个人的使用习惯设置等等,做成了一个脚本,可以一键设置win7的系统设置,比如更新提醒,关闭防火墙提示,烦人的系 ...CF912D Fishes 期望的更多相关文章
随机推荐