H. Degenerate Matrix

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/549/problem/H

Description

The determinant of a matrix 2 × 2 is defined as follows:

A matrix is called degenerate if its determinant is equal to zero.

The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements.

You are given a matrix . Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||.

Input

The first line contains two integers a and b (|a|, |b| ≤ 109), the elements of the first row of matrix A.

The second line contains two integers c and d (|c|, |d| ≤ 109) the elements of the second row of matrix A.

Output

Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10 - 9.

Sample Input

1 2
3 4

Sample Output

0.2000000000

HINT

题意

给你一个矩阵,然后要求俩矩阵中元素相剪的最大值最小,求第二个矩阵

第二个矩阵满足ad-bc=0

题解:

2种方法可以解决这个问题

1.推公式

2.二分答案

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int main()
{
ll a,b,c,d;
//double a1,b1,c1,d1;
cin>>a>>b>>c>>d;
ll tmp=abs(a+b+c+d);
tmp=max(tmp,abs(d+c-a-b));
tmp=max(abs(d+b-a-c),tmp);
tmp=max(abs(b+c-d-a),tmp);
if(tmp==)
cout<<""<<endl;
else
{
printf("%.12lf",(.*abs(a*d-b*c)/(.*tmp)));
}
}

Looksery Cup 2015 H. Degenerate Matrix 数学的更多相关文章

  1. 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 ...

  2. codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱

    #include <cstdio> #include <cstring> #include <algorithm> #include <string> ...

  3. Looksery Cup 2015 Editorial

    下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...

  4. Looksery Cup 2015

    A题水 C题 博弈论,如果不是CF有WA具体哪个点错了和数据的话,AC要难许多. 如果D的操作数大于奇数个数直接Win 偶数个数大于等于n – k 时,S直接Win 偶数个数小于n – k时,若D操作 ...

  5. Looksery Cup 2015 A. Face Detection 水题

    A. Face Detection Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  6. Looksery Cup 2015 B. Looksery Party 暴力

    B. Looksery Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/pro ...

  7. Looksery Cup 2015 F - Yura and Developers 单调栈+启发式合并

    F - Yura and Developers 第一次知道单调栈搞出来的区间也能启发式合并... 你把它想想成一个树的形式, 可以发现确实可以启发式合并. #include<bits/stdc+ ...

  8. Looksery Cup 2015 C. The Game Of Parity —— 博弈

    题目链接:http://codeforces.com/problemset/problem/549/C C. The Game Of Parity time limit per test 1 seco ...

  9. 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 ...

随机推荐

  1. iOS学习笔记之回调(一)

    什么是回调 看了好多关于回调的解释的资料,一开始总觉得这个概念理解起来有点困难,可能是因为自己很少遇到这种类型的调用吧.探索良久之后,才算有点启发,下面是自己的一点理解. 我们知道,在OSI网络七层模 ...

  2. Building nginx from Sources(从源代码安装nginx)

    Building nginx from Sources(从源代码安装nginx) The build is configured using the configure command.  安装用配置 ...

  3. Ruby on Rails vs. PHP vs. Python

    开发者在开发web应用时,往往会对平台的选择感到困惑,而web专家通常会建议:要考虑几个因素,这些因素包括周转时间.质量.跨浏览器兼容性.与其他框架的整合.数据安全性.易于访问性等. 在考虑了这些因素 ...

  4. 【转】Linux下的多线程编程

    1 引言 线程(thread)技术早在60年代就被提出,但真正应用多线程到操作系统中去,是在80年代中期,solaris是这方面的佼佼者.传统的 Unix也支持线程的概念,但是在一个进程(proces ...

  5. Debian openvpn 配置

    1.安装openvpn 和 iptables -- Debain 可以使用命令行`apt-get install openvpn iptables` 2.配置服务器 -- ```shell cp -R ...

  6. 【Hadoop代码笔记】Hadoop作业提交之Job初始化

    一.概要描述 在上一篇博文中主要描述了JobTracker和其几个服务(或功能)模块的接收到提交的job后的一些处理.其中很重要的一部分就作业的初始化.因为代码片段图的表达问题,本应该在上篇描述的内容 ...

  7. 正整数N是否是素数

    来自:[数据结构与算法分析——C语言描述]练习2.13 问题描述: a. 编写一个程序来确定正整数N是否是素数. b. 你的程序在最坏的情形下的运行时间是多少(用N表示)? c. 令B等于N的二进制表 ...

  8. MyEclipse中消除frame引起的“the file XXX can not be found.Please check the location and try again.”的错误

    读者如要转载,请标明出处和作者名,谢谢. 地址01:http://space.itpub.net/25851087 地址02:http://www.cnblogs.com/zjrodger/ 作者名: ...

  9. HashSet与HashMap、Hashtable

    (最近在老师叫我们用java去实现LRU算法,了解到要用双链表去做,要用到LinkHashMap去做,但自己对java的几大集合框架并不熟悉,在学习过程了解到了HashMap和HashSet,做个简单 ...

  10. HTML5-企业宣传6款免费源码

    本文主要分享了6个很不错的HTML5宣传模板源码,这些生动具体的介绍了各个公司的产品及公司各类应用,有汽车.旅游.公司,房产等Query特效,大家一起来欣赏吧. 一.九秒教育企业海报(移动端)这次要分 ...