CF549H:Degenerate Matrix ——题解
https://vjudge.net/problem/CodeForces-549H
————————————————————————
题目大意:给一个矩阵,每个数可以加任意的数使得该矩阵为退化矩阵(ad-bc=0),求每个数加的数的绝对值最大的最小值。
————————————————————————————
这题坑在看不懂题……
题解参考这个:http://blog.csdn.net/qq_26122039/article/details/53120339
这里再重新叙述一下吧:
首先二分最大值mid,这样每个数都可以最大上下浮动mid。
我们求出来这种情况下ad和bc的取值范围,只要他们的取值范围相交,就一定能达到条件。
——————————————————————————————
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
const int M=;
double ans,a,b,c,d;
bool pan(double m){
double a1=a+m;double a2=a-m;double b1=b+m;double b2=b-m;
double c1=c+m;double c2=c-m;double d1=d+m;double d2=d-m;
double t1=min(min(a1*d1,a1*d2),min(a2*d1,a2*d2));
double t2=min(min(b1*c1,b1*c2),min(b2*c1,b2*c2));
double x1=max(max(a1*d1,a1*d2),max(a2*d1,a2*d2));
double x2=max(max(b1*c1,b1*c2),max(b2*c1,b2*c2));
if(t1<=x2&&t2<=x1)return ;
return ;
}
void erfen(double l,double r){
for(int i=;i<=;i++){
double mid=(l+r)/;
if(pan(mid))ans=l=mid;
else r=mid;
}
return;
}
int main(){
cin>>a>>b>>c>>d;
erfen(,1e9);
printf("%.10lf\n",ans);
return ;
}
CF549H:Degenerate Matrix ——题解的更多相关文章
- Looksery Cup 2015 H. Degenerate Matrix 数学
H. Degenerate Matrix Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/549/ ...
- Codeforces 549H. Degenerate Matrix 二分
二分绝对值,推断是否存在对应的矩阵 H. Degenerate Matrix time limit per test 1 second memory limit per test 256 megaby ...
- 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 ...
- [LeetCode] 01 Matrix 题解
题意 # 思路 我一开始的时候想的是嘴 # 实现 ```cpp // // include "../PreLoad.h" class Solution { public: /** ...
- codeforces Looksery Cup 2015 H Degenerate Matrix 二分 注意浮点数陷阱
#include <cstdio> #include <cstring> #include <algorithm> #include <string> ...
- CF289B Polo the Penguin and Matrix 题解
Content 有一个 \(n\times m\) 的矩阵 \(A\),每次操作你可以将某一个元素增加或减少 \(d\),求是所有元素相等的最小操作次数,或者不存在这样的操作方案. 数据范围:\(1\ ...
- CF1042E Vasya and Magic Matrix 题解
题目链接 思路分析 看到题目中 \(n,m \leq 1000\) ,故直接考虑 \(O(n^2)\) 级别做法. 我们先把所有的点按照 \(val\) 值从小到大排序,这样的话二维问题变成序列问题. ...
- AGC027 D - Modulo Matrix 构造
目录 题目链接 题解 代码 题目链接 AGC027 D - Modulo Matrix 题解 从第左上角第一个点开始染色,相邻不同色,染法唯一 那么一个点的四周与他不同色,我们另这个点比四周都大,那么 ...
- [Leetcode Week13]Search a 2D Matrix
Search a 2D Matrix 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/search-a-2d-matrix/description/ D ...
随机推荐
- 「专题训练」Machine Schedule(HDU-1150)
题意 在一个工厂,有两台机器\(A, B\)生产产品.\(A\)机器有\(n\)种工作模式(模式\(0\),模式\(1\)--模式\(n-1\)).\(B\)机器有\(m\)种工作模式(模式\(0\) ...
- 使用python+selenium控制手工已打开的浏览器
我们可以利用Chrome DevTools协议.它允许客户检查和调试Chrome浏览器. 打开cmd,在命令行中输入命令: chrome.exe --remote-debugging-port=922 ...
- ## 在webapp上使用input:file, 指定capture属性调用默认相机,摄像,录音功能
在iOS6下开发webapp,使用inputz之file,很有用 <input type="file" accept="image/*" capture= ...
- LeetCode 96——不同的二叉搜索树
1. 题目 2. 解答 以 \(1, 2, \cdots, n\) 构建二叉搜索树,其中,任意数字都可以作为根节点来构建二叉搜索树.当我们将某一个数字作为根节点后,其左边数据将构建为左子树,右边数据将 ...
- [leetcode-775-Global and Local Inversions]
We have some permutation A of [0, 1, ..., N - 1], where N is the length of A. The number of (global) ...
- 基于angular+bower+glup的webapp
一:bower介绍 1:全局安装安装bower cnpm i -g bower bower常用指令: bower init //初始化文件 bower install bower uninstall ...
- Python中__name__属性的妙用
在Python中,每一个module文件都有一个built-in属性:__name__,这个__name__有如下特点: 1 如果这个module文件是被别的文件导入的,那么,该__name__属性的 ...
- UVALive - 6864 Strange Antennas 扫描线
题目链接: http://acm.hust.edu.cn/vjudge/problem/87213 Strange Antennas Time Limit: 3000MS 题意 一个雷达能够辐射到的范 ...
- joomla 出现The file Cache Storage is not supported on this platform;
错误提示:The file Cache Storage is not supported on this platform:在这个平台上不支持文件缓存存储 出现这样的原因很简单,有两个文件夹不可写,这 ...
- XDA-University: Getting Started
XDA-University: Getting Started A while back, we introduced XDA-University to the world, an ongoing ...