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 ...
随机推荐
- SQL SERVER修改字段为首字母大写
--修改字段为首字母大写 -- EXEC sp_rename 'ShenBao_CaiGouFuKuan.Tid', 'Tid', @objtype = 'COLUMN'; SELECT 'EXEC ...
- java基础知识入门
一.java简介及原理图 Java的前世今生 Java之父詹姆斯·高斯林: 1967年, 12岁用报废的电话机和电视做了一台电子游戏机; 1983年, 获得卡内基梅隆大学计算机科学博士学位; 1983 ...
- Sumitomo Mitsui Trust Bank Programming Contest 2019 Task F. Interval Running
Link. There is a nice approach to this problem that involves some physical insight. In the following ...
- spring-boot-plus集成Shiro+JWT权限管理
SpringBoot+Shiro+JWT权限管理 Shiro Apache Shiro是一个强大且易用的Java安全框架,执行身份验证.授权.密码和会话管理. 使用Shiro的易于理解的API,您可以 ...
- String Class
#include <iostream> #include <fstream> #include <sstream> using namespace std; tem ...
- 正则表达式split匹配多种例如 “】”,“,”两种(页面级中英文切换方案)
在做登陆界面的时候,因为涉及到中英文 因为前后台已经分离,所以前端需要自行设计中英文 做法: 编写两个文件,一个中文文件,一个是英文文件,分别放在对应的目录下面 文件的内容 { "login ...
- 微信小程序异步回调
场景如下:现有一个方法需要等待其他N个异步函数执行完毕后执行,callback麻烦的头大,翻了一波API原来小程序已经支持 async函数,那一切就好办了. 废话不多说,直接开始撸... 第一步:打开 ...
- bootstrap-selectpicker 插件事件
$('#id').on('show.bs.select', function (e) { //绑定下拉显示列表触发事件 }); $('#id').on('hidden.bs.select', func ...
- 利用axis调用webservice接口
一.首先把wsdl文件放入eclipse中某个项目中的src目录下 二.右键弹出webservice,然后点击webservice菜单,选中genernator client ,选择axis生成Jav ...
- 6.移动端自动化测试-小知识 if __name__==’__main__:是什么意思?
1 引言 在Python当中,如果代码写得规范一些,通常会写上一句“if __name__==’__main__:”作为程序的入口,但似乎没有这么一句代码,程序也能正常运行.这句代码多余吗?原理又在哪 ...