XidianOJ 1081 锘爷与矩阵

题目描述

 

锘爷有一二阶方阵A={Aij},且

A11=a, A12=b, A21=c, A22=d

我们都知道,矩阵A的行列式的值

det(A) = ad - bc

现在你知道a的取值范围为闭区间[a1,a2]内的实数,同样的,b为[b1,b2],c为[c1,c2],d为[d1,d2],你的任务是判断是否存在使得det(A)=0的矩阵A。

输入

多组数据,处理到EOF。

每组数据包含一行,每行为8个正整数,分别表示a1, a2, b1, b2, c1, c2, d1, d2,且8个数都在[1,108]范围内,而且a1<=a2, b1<=b2, c1<=c2, d1<=d2。

输出

对于每组数据,如果存在符合条件的矩阵,输出“YES”,否则输出“NO”。

--正文
这题意外的耿直啊
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;
LL a1,a2,b1,b2,c1,c2,d1,d2;

int main(){
    while (scanf("%lld%lld%lld%lld%lld%lld%lld%lld",&a1,&a2,&b1,&b2,&c1,&c2,&d1,&d2) != EOF){
        LL max = (a2*d2) - (b1*c1);
        LL min = (a1*d1) - (b2*c2);
        if (min > 0 || max < 0) {
            printf("NO
");
        }
        else {
            printf("YES
");
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/ToTOrz/p/6084599.html