牛客小白月赛67—— 一刀二分三角(数学)

https://ac.nowcoder.com/acm/contest/51458/C

题目大意:

给定一个三角形,三个点分别是(0,0)(xc,yc)(xb,0)。
​
问我们是否可以将三角形沿着x=某个数字切开,得到的两个平面图形面积相同。

可以输出“YES”,不行输出“NO”。

注意0<=xc<=xb。
输入 
3
4 2 4
27 3 15
25 13 22
输出 
YES
YES
NO

如果使用double的话会产生精度问题,所以我们在写题时,应把全部转化为除法来进行。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-1e18;
const LL N=1e6+10,M=4010;
const LL mod=998244353;
const double PI=3.1415926535;
#define endl '\n'
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)
    {
        LL xb,xc,yc;
        cin>>xb>>xc>>yc;
        bool flag=false;
        for(int i=0;i<=xc;i++)
        {
            if(2*i*i==xc*xb)
            {
                flag=true;
                break;
            }
        }
        if(flag==false)
        {
            for(int i=xc;i<=xb;i++)
            {
                if((xb-xc)*xb==2*i*i)
                {
                    flag=true;
                    break;
                }
            }
        }
        if(flag==true) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
posted @ 2023-03-02 20:26  高尔赛凡尔娟  阅读(40)  评论(0编辑  收藏  举报