Looksery Cup 2015 H. Degenerate Matrix 数学
H. Degenerate Matrix
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/549/problem/H
Description
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 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 数学的更多相关文章
- 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 ...
- codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱
#include <cstdio> #include <cstring> #include <algorithm> #include <string> ...
- Looksery Cup 2015 Editorial
下面是题解,做的不好.下一步的目标是rating涨到 1800,没打过几次cf A. Face Detection Author: Monyura One should iterate through ...
- Looksery Cup 2015
A题水 C题 博弈论,如果不是CF有WA具体哪个点错了和数据的话,AC要难许多. 如果D的操作数大于奇数个数直接Win 偶数个数大于等于n – k 时,S直接Win 偶数个数小于n – k时,若D操作 ...
- 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 ...
- Looksery Cup 2015 F - Yura and Developers 单调栈+启发式合并
F - Yura and Developers 第一次知道单调栈搞出来的区间也能启发式合并... 你把它想想成一个树的形式, 可以发现确实可以启发式合并. #include<bits/stdc+ ...
- 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 ...
- 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 ...
随机推荐
- DevExpress 14.2.3源码编译 z
一.准备 1.准备一台Windows 8.1机器,安装VS2013 2.准备一台Windows 8.1机器,安装VS2010 XP的系统肯定不行,因为有不少的运行库不支持 Windows ...
- Textbox像百度一下实现下拉显示 z
List<string> Data = new List<string>(); string Randomstr = "功夫撒黑胡椒hcbvf蜂窝qwertyuiop ...
- 2014 IGF 评选(转)
前两天受邀去上海参加今年的独立游戏节评选,准确说是亚洲及太平洋地区的 IGF . 居然有接近 400 个参选游戏是让我事前没有想到的,尤其是在学生组还发现了不少好作品是个惊喜. 评审用了整整两天时间, ...
- 【C#】构造函数的特点
1.它的函数名与类名相同:2.它可以重载:3.不能指定返回类型,即使是void也不行:4.虽然在一般情况下,构造函数不被显式调用,而是在创建对象时自动被调用.但是并不是不能被显示调用.有些时候是一定要 ...
- vim 配置语法高亮 行号标示
配置VIM主要是开启VIM的语法高亮和行号标示,因为默认在用户目录(~)下没有vimrc,所以需要先去复制一个,然后再编辑 cp /etc/vim/vimrc ~/.vimrc vim .vimrc ...
- Flex 对Java端返回Collection的处理方法
将Flex与Spring集成后(BlazeDS 与Spring集成指南 ),第一个面临的问题就是:对于Java端返回的各种Java类型的对象,Flex中能否有相应的数据类型来映射. 处理,尤其是Lis ...
- 微软Azure云主机测试报告
http://www.cnblogs.com/sennly/p/4135658.html 1. 测试目的 本次测试的目的在于对微软云主机做性能测试,评估其是否能够满足我们业务的需求. 2. 测试项目 ...
- Java基础 —— 面向对象
面向对象的程序设计: 1. 基本特征:抽象性,封装性,继承性,多态性. 2. 类及成员的访问控制:private:同一类中: default:同一包中: protected:子类中: public:全 ...
- HashSet与HashMap、Hashtable
(最近在老师叫我们用java去实现LRU算法,了解到要用双链表去做,要用到LinkHashMap去做,但自己对java的几大集合框架并不熟悉,在学习过程了解到了HashMap和HashSet,做个简单 ...
- C++11类型推导
[C++11类型推导] auto 关键字.这会依据该初始化子(initializer)的具体类型产生参数: 除此之外,decltype 能够被用来在编译期决定一个表示式的类型. 参考:http://z ...