CodeForces 549H | 二分答案
参考了这个博客哇
#include<cstdio>
#include<algorithm>
#include<cstring>
#define Max(a,b,c,d) max(max(a,b),max(c,d))
#define Min(a,b,c,d) min(min(a,b),min(c,d))
using namespace std;
double a,b,c,d,l,r=1000000000,mid;
bool check(double lim)
{
double max_x=Max((a+lim)*(d+lim),(a-lim)*(d-lim),(a+lim)*(d-lim),(a-lim)*(d+lim));
double min_x=Min((a+lim)*(d+lim),(a-lim)*(d-lim),(a+lim)*(d-lim),(a-lim)*(d+lim));
double max_y=Max((b+lim)*(c+lim),(b+lim)*(c-lim),(b-lim)*(c-lim),(b-lim)*(c+lim));
double min_y=Min((b+lim)*(c+lim),(b+lim)*(c-lim),(b-lim)*(c-lim),(b-lim)*(c+lim));
if(max_x-min_y>=0&&min_x-max_y<=0)
return 1;
else return 0;
}
int main()
{
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
for (int i=1;i<=100;i++)
{
mid=(l+r)/2;
if (check(mid)) r=mid;
else l=mid;
}
printf("%.10lf",l);
return 0;
}
CodeForces 549H | 二分答案的更多相关文章
- Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论
n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...
- codeforces 359D 二分答案+RMQ
上学期刷过裸的RMQ模板题,不过那时候一直不理解>_< 其实RMQ很简单: 设f[i][j]表示从i开始的,长度为2^j的一段元素中的最小值or最大值 那么f[i][j]=min/max{ ...
- Electric Charges CodeForces - 623C (二分答案)
大意: 平面上n个点每个点坐标为(x,0)或(0,y), 求任意两点距离平方最大值的最小值. 二分答案, 转化为判定最大值是否<=e, 按$x$排序后, 因为固定左端点, $y$绝对值的最大值是 ...
- Codeforces 1132D(二分答案+堆)
题面 传送门 分析 二分答案,考虑如何判定 可以用贪心的方法,每次找最快没电的电脑,在没电前1单位时间给它充电 正确性显然 实现上可以维护一个堆,存储每个电脑电用完的时刻,每次从堆顶取出最小的一个给它 ...
- CodeForces 483B 二分答案
题目: B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces 700A As Fast As Possible(二分答案)
[题目链接] http://codeforces.com/problemset/problem/700/A [题目大意] 有一辆限载k人速度为v2的车,n个步行速度均为v1的人要通过一段长度为l的距离 ...
- Codeforces Round #276 (Div. 1) E. Sign on Fence (二分答案 主席树 区间合并)
链接:http://codeforces.com/contest/484/problem/E 题意: 给你n个数的,每个数代表高度: 再给出m个询问,每次询问[l,r]区间内连续w个数的最大的最小值: ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划
There are n people and k keys on a straight line. Every person wants to get to the office which is l ...
- Codeforces 772A Voltage Keepsake - 二分答案
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per s ...
随机推荐
- Redux初识
1.定义规则counter 2.根据计算规则生成store let store=createStore(counter); 3.订阅消息(state 发生变化后发送消息) 4.触发规则,使state发 ...
- Oracle多表连接方法
笛卡尔连接[结果集为各表记录的乘积] SELECTt * FROM table_1, table_2, table_n SELECTt * FROM table_1 CROSS JOIN table_ ...
- Spring Cloud 升级最新 Finchley 版本,踩坑指南!
https://blog.csdn.net/youanyyou/article/details/81530240 Spring Cloud 升级最新 Finchley 版本,踩了所有的坑! 2018年 ...
- 【转载】C#批量插入数据到Sqlserver中的三种方式
引用:https://m.jb51.net/show/99543 这篇文章主要为大家详细介绍了C#批量插入数据到Sqlserver中的三种方式,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 本篇, ...
- 天气预报api-汇总
和风天气 https://www.heweather.com/
- Redis数据库 : python与java操作redis
redis 包 from redis import * 连接: r = StrictRedis(host='localhost', port='6379') 读写:r.set('key','value ...
- Fruits【水果】
Fruits Many of us love July because it's the month when nature's berries and stone fruits are in abu ...
- P1582倒水 位运算
题目描述 一天,CC买了N个容量可以认为是无限大的瓶子,开始时每个瓶子里有1升水.接着~~CC发现瓶子实在太多了,于是他决定保留不超过K个瓶子.每次他选择两个当前含水量相同的瓶子,把一个瓶子的水全部倒 ...
- [Bzoj2246]迷宫探险(概率+DP)
Description 题目链接 Solution 用三进制表示陷阱状态,1表示有害,2表示无害,0表示不知道 用\(f[S][i]\)表示状态为S时陷阱i有害的概率,这个可以预处理出 \(d[S][ ...
- python向多个邮箱发邮件--注意接收是垃圾邮件
群发邮件注意:三处标红的地方 # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText from emai ...