题意翻译

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 .

输入输出样例

输入样例#1:
复制

3 3 2 3
输出样例#1: 复制

2.0000000000
输入样例#2: 复制

12 17 9 40
输出样例#2: 复制

32.8333333333

说明

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.

很容易想到的一种思路是在被正方形覆盖次数最多的地方放

CF912D Fishes 期望的更多相关文章

  1. CF912D Fishes 期望 + 贪心

    有趣的水题 由期望的线性性质,全局期望 = 每个格子的期望之和 由于权值一样,我们优先选概率大的点就好了 用一些数据结构来维护就好了 复杂度$O(k \log n)$ #include <set ...

  2. [CF912D]Fishes - 求数学期望,乱搞

    D. Fishes time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

  3. CF912D Fishes

    题目链接:http://codeforces.com/contest/912/problem/D 题目大意: 在一个\(n \times m\)的网格中放鱼(每个网格只能放一条鱼),用一个\(r \t ...

  4. CodeForces 912d fishes(优先队列+期望)

    While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of ...

  5. Codeforces 912D Fishes (概率&期望,优先队列的应用)

    题目链接 Fishes 题意  在一个$n*m$的矩阵中,随机选择一个$r * r$的区域覆盖. 一开始我们可以在这个$n*m$的矩阵中选择$k$个点标记为$1$. 我们要选择一个最佳的标记策略,使得 ...

  6. cf期望概率专题

    cf1009E:求到第i段期望和的比较困难,但是单独求每段的期望是比较容易的,所以单独对每段求和,然后累计总和 E[i]=1/2*a1+1/4*a2+...+1/2^(i-1)*ai-1+1/2^(i ...

  7. 【BZOJ-3143】游走 高斯消元 + 概率期望

    3143: [Hnoi2013]游走 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2264  Solved: 987[Submit][Status] ...

  8. bzoj1415[NOI2005]聪聪和可可-期望的线性性

    这道题之前我写过一个巨逗比的写法(传送门:http://www.cnblogs.com/liu-runda/p/6220381.html) 当时的原因是这道题可以抽象出和"绿豆蛙的归宿&qu ...

  9. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

随机推荐

  1. 第四章 Java并发编程基础

    线程简介 什么是线程? 现代操作系统在一个运行程序时,会为其创建一个进程.例如,启动一个Java程序,操作系统就会创建一个Java进程.现代操作系统调度的最小单元是线程,也叫轻量进程(Light We ...

  2. java,js判断全角半角

    function chkHalf(str){ for(var i=0;i { strCode=str.charCodeAt(i); if((strCode>65248)||(strCode==1 ...

  3. python爬虫(10)--PyQuery的用法

    简介 pyquery 可让你用 jQuery 的语法来对 xml 进行操作.这I和 jQuery 十分类似.如果利用 lxml,pyquery 对 xml 和 html 的处理将更快. 初始化 在这里 ...

  4. UML在实践中的现状和一些建议

    本文是我在csdn上看到的文章,由于认识中的共鸣,摘抄至此. 原文地址:http://blog.csdn.net/vrman/article/details/280157 UML在国内不少地方获得了应 ...

  5. latex学习

    第一段代码 \documentclass{article} \usepackage{ctex} \begin{document} \section{文字} 特可爱模板 \section{数学} \[ ...

  6. Swing事件机制

    -------------siwuxie095                             Swing 是基于 MVC 结构的框架     在 Swing 中,所有的用户操作都是基于 Co ...

  7. Ros学习——导航

    1.导航框架 在总体框架图中可以看到,move_base提供了ROS导航的配置.运行.交互接口,它主要包括两个部分:      (1) 全局路径规划(global planner):根据给定的目标位置 ...

  8. css 层叠式样式表(1)

    实用css有三种格式:内嵌:内联:外部: 分类:内联:写在标记的属性位置,优先级最高,重用性最差内嵌:写在页面的head中,优先级第二,重用性一般外部:写在一个以css结尾的文件中,通过引用来建立文件 ...

  9. Tensorflow 优化学习

    # coding: utf-8 import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data pr ...

  10. R: 字符串处理包:stringr

    本文摘自:  http://blog.fens.me/r-stringr/ 1. stringr介绍 stringr包被定义为一致的.简单易用的字符串工具集.所有的函数和参数定义都具有一致性,比如,用 ...