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 ...
随机推荐
- kafka2.10集群搭建(一)
一.kafka集群搭建 1.上传解压 2.配置文件的配置 1.修改 server.properties文件 broker.id=11 #192.168.199.11 #21 一般使用ip后三位 lis ...
- MVCC原理 4步 什么是MVCC、事务ACID、事物隔离级别、Innodb存储引擎是如何实现MVCC的
MVCC是来处理并发的问题,提高并发的访问效率,读不阻塞写.事物A 原子性C 一致性I 隔离性D 持久性高并发的场景下的问题脏读不可重复读幻读事物隔离级别RU读未提交 脏读/不可重复读/幻读 .不适用 ...
- Linux 创建用户 用户组 用户权限
首先 你要有个root账号 然后才能做下面几条操作: useradd username 创建用户usernamepasswd user_pwd 给已创建的用户username设置密码 关于us ...
- 复习二叉数 pat l2-006 数的遍历
L2-006. 树的遍历 给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列.这里假设键值都是互不相等的正整数. 输入格式: 输入第一行给出一个正整数N(<=30),是二叉树中结点 ...
- Java集合--Hash、Hash冲突
一.Hash 散列表(Hash table,也叫哈希表),是根据键(Key)而直接访问在内存存储位置的数据结构.也就是说,它通过计算一个关于键值的函数,将所需查询的数据映射到表中一个位置来访问记录,这 ...
- DotNet跨平台 - .net core项目部署到centos7
环境说明 系统:CentOS Linux release 7.2.1511 (Core) 相关工具:VS2017 xftp 服务器软件:.net core2.0,nginx 准备.net core应 ...
- c++11 常量表达式
c++11 常量表达式 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #inclu ...
- [转载]边框回归(Bounding Box Regression)
[转载]边框回归(Bounding Box Regression) 许多模型中都应用到了这种方法来调整piror使其和ground truth尽量接近,例如之前自己看过的SSD模型 这篇文章写的很好, ...
- python numpy array 的sum用法
如图: sum可以指定在那个轴进行求和: 且第0轴是纵向,第一轴是横向:
- 深入理解hadoop之mapreduce
本文系原创,若有转载需要,请注明出处.https://www.cnblogs.com/bigdata-stone/ 1.mapReduce简介 MapReduce是面向大数据并行处理的计算模型.框架和 ...