codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
bool fun(double l1,double r1,double l2,double r2){
return (l1 <= r2 && l1 >= l2) || (l2 >= l1 && l2 <= r1);
}
int main() {
double a,b,c,d;
cin >> a >> b >> c >> d; double r = 1000000000.0;
double l = 0; for(int i = 0;i < 1000;i++){ double m = l + (r - l) /2.0;
double a1 = (a-m)*(d-m);
double a2 = (a-m)*(d+m);
double a3 = (a+m)*(d-m);
double a4 = (a+m)*(d+m);
double l1 = min(min(a1,a2),min(a3,a4));
double r1 = max(max(a1,a2),max(a3,a4));
a1 = (c-m)*(b-m);
a2 = (c-m)*(b+m);
a3 = (c+m)*(b-m);
a4 = (c+m)*(b+m);
double l2 = min(min(a1,a2),min(a3,a4));
double r2 = max(max(a1,a2),max(a3,a4));
if(fun(l1,r1,l2,r2)){
r = m;
}
else{
l = m;
}
}
printf("%.10f\n",l);
return 0; }
codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱的更多相关文章
- codeforces Looksery Cup 2015 H Degenerate Matrix
The determinant of a matrix 2 × 2 is defined as follows: A matrix is called degenerate if its determ ...
- Looksery Cup 2015 H. Degenerate Matrix 数学
H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...
- codeforces Looksery Cup 2015 D. Haar Features
The first algorithm for detecting a face on the image working in realtime was developed by Paul Viol ...
- codeforces Looksery Cup 2015 C. The Game Of Parity
There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play t ...
- Codeforces 549H. Degenerate Matrix 二分
二分绝对值,推断是否存在对应的矩阵 H. Degenerate Matrix time limit per test 1 second memory limit per test 256 megaby ...
- Looksery Cup 2015 Editorial
下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...
- Codeforces VK CUP 2015 D. Closest Equals(线段树+扫描线)
题目链接:http://codeforces.com/contest/522/problem/D 题目大意: 给你一个长度为n的序列,然后有m次查询,每次查询输入一个区间[li,lj],对于每一个查 ...
- Looksery Cup 2015 A. Face Detection 水题
A. Face Detection Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...
- Looksery Cup 2015 B. Looksery Party 暴力
B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...
随机推荐
- 远程视频监控之驱动篇(LED)
转载请注明出处:http://blog.csdn.net/ruoyunliufeng/article/details/38515205 之前一直在考虑该不该写这篇,由于我之前在博客里有写过LED的驱动 ...
- wpf获取webbroswer的两个方法
//跳转前的地址 private void WebBrowser_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref ...
- BZOJ 1500 splay终结版...
GSS系列有一丝丝像- 只不过那个是线段树 这个是splay 翻转 插入 删除啥的就是普通的splay 合在一起了而已 //By SiriusRen #include <cstdio> # ...
- marge into操作
动机: 想在Oracle中用一条SQL语句直接进行Insert/Update的操作. 说明: 在进行SQL语句编写时,我们经常会遇到大量的同时进行Insert/Update的语句 ,也就是说当存在记录 ...
- SQL Server 查询所有包含某文本的存储过程、视图、函数
• 方法一:查询所有包含某文本的存储过程.视图.函数 SELECT * from sysobjects o, syscomments s where o.id = s.id AND text LIK ...
- Bluefish Editor - 蓝鱼编辑器 for Web Designer
Bluefish is a GTK+ HTML editor for the experienced web designer. Its features include nice wizards f ...
- C# web api 中过滤器的使用
一.开篇 Fiter在Web API中经常会用到,主要用于记录日志,安全验证,全局错误处理等:Web API提供两种过滤器的基本类型:actionfilterattribute,exceptionfi ...
- Linux目录结构(一)
linux文件系统的最顶端是/,称为linux的root,所有的目录.文件.设备都在/之下. 文件类型 linux有四种基本文件系统类型:普通文件.目录文件.连续文件和特殊文件.可以用file命令来识 ...
- Android和IOS等效MD5加密
最近在Android和IOS上都需要对用户的某些输入进行简单的加密,于是采用MD5加密方式. 首先将目的字符串加密一次,获得32位字符串 然后将32位字符串拆为2段,分别加密1次 最后将加密后的2段拼 ...
- 如何在使用layer.prompt在输入值为空的情况下点击确定继续执行逻辑?
突然发现在使用LayUI时,用到弹出层layer.prompt时,如果文本框输入值是空的话点击确定没有反应,不能向下执行. 但是我又需要在这种情况下去继续执行判断或逻辑时该怎么做?? 示例:原代码如下 ...