题:

  OvO http://codeforces.com/contest/912/problem/D

解:

  枚举每一条鱼,每放一条鱼,必然放到最优的位置,而最优位置即使钓上的概率最大的位置,即最多的r*r矩形覆盖住的点

  可以把这个鱼塘分为田字型4个相同的部分(可重叠),

  取其中一个部分,显然最开始的最优位置是最靠近中心的位置,

  维护一个优先队列,优先度为点出现在多少个r*r的矩形中,

  每次从优先队列中取出一个点,则可以求出在其他部分上有多少不重叠的点和这个点对称,则可以同时进行计算。

  枚举到k个点结束

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map> #define double long double using namespace std; typedef long long ll; const ll bas=1e9+44; struct node
{
int a,b;
ll c;
friend bool operator<(node x,node y)
{
return x.c<y.c;
}
}; map<ll,bool>mp;
priority_queue<node> que;
int n,m,r,k,nc,mc,nw,mw; int getNum(int a,int b)
{
if((a==(n+1)/2 && (n&1)) && (b==(m+1)/2 && (m&1))) return 1;
if((a==(n+1)/2 && (n&1)) || (b==(m+1)/2 && (m&1))) return 2;
return 4;
} double getPsi(ll c)
{
return 1.0*c/nw/mw;
} void solve()
{
mp.clear();
node tmp,now;
double psi,ans=0;
int num;
while(!que.empty())
que.pop();
now.a=(n+1)/2,now.b=(m+1)/2,now.c=1ll*min(nc,now.a)*min(mc,now.b);
que.push(now),mp[bas*now.a+now.b]=1;
while(k>0)
{
now=que.top(),que.pop();
num=getNum(now.a,now.b),num=min(num,k);
psi=getPsi(now.c);
// cout<<now.a<<' '<<now.b<<' '<<now.c<<' '<<num<<' '<<psi<<endl;
ans+=psi*num;
k-=num;
tmp.a=now.a-1,tmp.b=now.b,tmp.c=1ll*min(nc,tmp.a)*min(mc,tmp.b);
if(tmp.a>0 && tmp.b>0 && mp[bas*tmp.a+tmp.b]==0) que.push(tmp),mp[bas*tmp.a+tmp.b]=1;
tmp.a=now.a,tmp.b=now.b-1,tmp.c=1ll*min(nc,tmp.a)*min(mc,tmp.b);
if(tmp.a>0 && tmp.b>0 && mp[bas*tmp.a+tmp.b]==0) que.push(tmp),mp[bas*tmp.a+tmp.b]=1;
}
printf("%.12Lf\n",ans);
} int main()
{
scanf("%d%d%d%d",&n,&m,&r,&k);
nw=nc=n-r+1,mw=mc=m-r+1;
nc=min(r,nc),mc=min(r,mc);
solve();
return 0;
} /* 10 10 1 100 */

  

Codeforces Round #456 (Div. 2) 912D D. Fishes的更多相关文章

  1. Codeforces Round #456 (Div. 2)

    Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶, ...

  2. Codeforces Round #456 (Div. 2) B. New Year's Eve

    传送门:http://codeforces.com/contest/912/problem/B B. New Year's Eve time limit per test1 second memory ...

  3. Codeforces Round #456 (Div. 2) A. Tricky Alchemy

    传送门:http://codeforces.com/contest/912/problem/A A. Tricky Alchemy time limit per test1 second memory ...

  4. Codeforces Round #456 (Div. 2) 912E E. Prime Gift

    题 OvO http://codeforces.com/contest/912/problem/E 解 首先把这个数字拆成个子集,各自生成所有大小1e18及以下的积 对于最坏情况,即如下数据 16 2 ...

  5. Codeforces Round #456 (Div. 2) B. New Year's Eve

    B. New Year's Eve time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  6. 【Codeforces Round #456 (Div. 2) A】Tricky Alchemy

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 统计需要的个数. 不够了,就买. [代码] #include <bits/stdc++.h> #define ll lo ...

  7. 【Codeforces Round #456 (Div. 2) B】New Year's Eve

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然10000..取到之后 再取一个01111..就能异或成最大的数字了. [代码] /* 1.Shoud it use long ...

  8. 【Codeforces Round #456 (Div. 2) C】Perun, Ult!

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] set1 < pair < int,int > > set1;记录关键点->某个人怪物永远打不死了,第 ...

  9. Codeforces Round #456 (Div. 2) B题

    B. New Year's Evetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputout ...

随机推荐

  1. Linux 下面安装 nginx 以及进行TCP反向代理、负载均衡的过程

    1. 下载安装nginx 注意 因为stream 并不是 nginx自带的module  所以需要 在安装是 通过 --with 的方式增加上. 下载必要的程序包 # openssl wget htt ...

  2. mysqldump原理及实战

    使用mysqldump命令行工具创建逻辑备份: 注意mysqldump的版本和路径mysqldump命令创建的是逻辑备份,结果集有两种格式:一种是将数据转换成标准的SQL语句(一堆CREATE,DRO ...

  3. shell使用ps -ef|grep xxx时不显示grep xxx进程的方法

    在使用ps -ef|grep xxx时会将grep xxx的进程也带出来, 而在脚本中如果想要截取此命令结果的一部分,则grep xxx的进程会显得多余,如下: [root@localhost ~]# ...

  4. 怎样获取从服务器返回的xml或html文档对象

    使用 xhr.responseXML;  通过这个属性正常获取XML或HTML文档对象有两个前置条件: 1. Content-Type头信息的值等于: text/xml 或 application/x ...

  5. postman中传参说明

    1.form-data 表单传递,对应multipart/form-data, 2.x-www-form-urlencoded 默认传递,对应application/x-www-from-urlenc ...

  6. POJ1845Sumdiv题解--约数之和

    题目链接 https://cn.vjudge.net/problem/POJ-1845 分析 \(POJ\)里的数学题总是这么妙啊 首先有一个结论就是\(A=\prod{ \ {p_i}^{c_i} ...

  7. css height属性中的calc方法

    例如父盒子是100%的高度 盒子里面的head部分固定位140px 内容部分始终为剩余的全部高度 height: calc(100% - 140px); 切结"+或-"两边要有空格 ...

  8. selenium在爬虫中的应用之动态数据爬取

    一.selenium概念 selenium 是一个基于浏览器自动化的模块 selenium爬虫之间的关联: 1.便捷的获取动态加载的数据 2.实现模拟登录 基本使用 pip install selen ...

  9. Nginx笔记一

      nginx: 为什么选择nginx: nginx是一个高性能的web和反向代理服务器. 作为web服务器:使用更少的资源,支持更多的并发连接,更高的效率,能够支持高达5w个并发连接数的相应, 作为 ...

  10. 数据库 master拒绝了 create database 权限

    1.通过windows身份验证方式登录 2.为登录名赋予服务器角色权限,其中dbcreator权限表示允许新增和修改权限,sysadmin权限是管理员权限,包含dbcreator范围,若不追求权限精准 ...