Codeforces looksery Cup of H degenerate Matrix binary note floating point trap

Source: Internet
Author: User
Tags min
#include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <cmath&
Gt
#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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.