Codeforces Round #456 (Div. 2) 912D D. Fishes
题:
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的更多相关文章
- Codeforces Round #456 (Div. 2)
Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶, ...
- 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 ...
- Codeforces Round #456 (Div. 2) A. Tricky Alchemy
传送门:http://codeforces.com/contest/912/problem/A A. Tricky Alchemy time limit per test1 second memory ...
- Codeforces Round #456 (Div. 2) 912E E. Prime Gift
题 OvO http://codeforces.com/contest/912/problem/E 解 首先把这个数字拆成个子集,各自生成所有大小1e18及以下的积 对于最坏情况,即如下数据 16 2 ...
- 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 ...
- 【Codeforces Round #456 (Div. 2) A】Tricky Alchemy
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 统计需要的个数. 不够了,就买. [代码] #include <bits/stdc++.h> #define ll lo ...
- 【Codeforces Round #456 (Div. 2) B】New Year's Eve
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然10000..取到之后 再取一个01111..就能异或成最大的数字了. [代码] /* 1.Shoud it use long ...
- 【Codeforces Round #456 (Div. 2) C】Perun, Ult!
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] set1 < pair < int,int > > set1;记录关键点->某个人怪物永远打不死了,第 ...
- Codeforces Round #456 (Div. 2) B题
B. New Year's Evetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputout ...
随机推荐
- [转帖]Linux-Windows 端口转发 netsh 还有 rinetd
Linux-Windows 端口转发 https://www.cnblogs.com/operationhome/p/11284559.html 之前自己学习过 netsh 也曾经用过frp 这次学习 ...
- ubuntu下安装navicat
1.去官网下载 https://www.navicat.com/en/download/navicat-premium 2.命令行输入(解压命令) tar -zxvf xxxxx.tar.gz 3.移 ...
- Rikka with Competition hdu 6095
签到题目,排序然后按序清理掉一定会输的结果就可以. ac代码: #include <iostream> #include <cstdio> #include <cstri ...
- Task资料
5天玩转C#并行和多线程编程:http://www.cnblogs.com/yunfeifei/p/3993401.html
- mysql中binglog底层原理分析
binglog 是一个二进制的日志文件,会记录mysql的数据更新或潜在个跟新 (delete from table where id =xxx) 主从复制就是依靠binglog master -sl ...
- Jerry和您聊聊Chrome开发者工具
Chrome开发者工具是Jerry日常工作使用的三大调试器之一.虽然工具名称前面带了个"开发者", 但是它对非开发人员仍然有用.不信? 用Chrome打开我们常用的网站,按F12, ...
- JTree实现QQ好友列表
最近学习了一下JTree的使用方法: 先来看一下树的实例: 构建一个树, DefaultMutableTreeNode root = new DefaultMutableTreeNode(" ...
- 常用Linux文件系统
- HTML5学习:表格
HTML代码 <table> <thead> <tr> <th>标题1</th> <th>标题2</th> < ...
- 《浏览器工作原理与实践》<04>从输入URL到页面展示,这中间发生了什么?
“在浏览器里,从输入 URL 到页面展示,这中间发生了什么? ”这是一道经典的面试题,能比较全面地考察应聘者知识的掌握程度,其中涉及到了网络.操作系统.Web 等一系列的知识. 在面试应聘者时也必问这 ...