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 ...
随机推荐
- ListView的adapter中getView方法一直调用
当ListView的高度不定(比如重写ListView搞成可自己主动的扩展的ListView)或 ListView嵌套在SrollView(高度不定)中,listView中的一个item元素改变会使得 ...
- java中字符串编码转换
Java 正确的做字符串编码转换 字符串的内部表示? 字符串在java中统一用unicode表示( 即utf-16 LE) , 对于 String s = "你好哦!"; 如果源码 ...
- 深入理解Oracle索引(1):INDEX SKIP SCAN 和 INDEX RANGE SCAN
㈠ Index SKIP SCAN 当表有一个复合索引,而在查询中有除了索引中第一列的其他列作为条件,并且优化器模式为CBO,这时候查询计划就有可能使用到SS ...
- Crawler4j快速入门实例
项目是基于maven 结构的. 首先我们在pom.xml中加入log4j以及log4j驱动类支持: <!-- 加入log4j支持 --> <dependency> <gr ...
- [实例]ROS使用OpenCV读取图像并发布图像消息在rviz中显示
思路: (1)使用opencv读取本地图像 (2)调用cv_bridge::CvImage().toImageMsg()将本地图像发送给rviz显示 一.使用opencv读取本地图像并发布图像消息 ( ...
- BZOJ 1989 概率相关
思路: 一条边免费的概率为 (经过它的路/总路径条数)^2 DFS即可 有个地方没有用 long long炸了好久- //By SiriusRen #include <cstdio> us ...
- 前端开发人员要注意的css规范,css命名。
刚工作的时候也没注意关于css的规则,根据自己的心情想怎么用就怎么用,完成工作就好不会考虑代码的可读性,加载的性能,现在身为前端的一员就要有程序员的自我修养(嘿嘿,是不是很有责任感啊). 废话不多说, ...
- Vue 菜单栏点击实现高亮显示
步骤: 遍历对象(goods)获取菜单栏每一项的对象(item)和下标(index) 添加点击事件toggle(),传入下标参数:@click="fn1();fn2()" 动态切换 ...
- C语言“%”运算符
C语言中运算符“%”是取余运算符,而非取模运算符.(运算符“%”在C/C++, JAVA中,为取余运算,而在Python中为取模运算) 对于一个C语言取余表达式a % b,设其值为result,有如下 ...
- 基于 Web 的 Go 语言 IDE - Wide 1.3.0 发布!
http://symphony.b3log.org/article/1437292757551 欢迎各位提意见.建议,参与到 Wide 开源项目中 :-)