P10245 Swimming Pool题解
P10245 Swimming Pool
题意
给你四条边 \(abcd\),求这四条边是否可以组成梯形。
思路
这显然是一道简单的普通数学题。
判断是否能构成梯形只需看四条边是否能满足,上底减下底的绝对值小于两腰之和且大于两腰之差。
证明过程
如图,\(AB=a\),\(BC=b\),\(CD=c\),\(AD=d\)。
过点 \(D\) 作 \(AB\) 的平行线交 \(BC\) 于点 \(E\)。
若四边形 \(ABCD\) 为梯形,则 \(AD\) 平行于 \(BE\),
又 \(AB\) 平行 \(DE\),
所以四边形 \(ABED\) 是平行四边形,
则 \(BE=AD=d\)。
因为 \(BC=b\),
所以 \(EC=BC-BE=b-d\)。
由上文知四边形 \(ABED\) 是平行四边形,
则 \(DE=AB=a\)。
于是在三角形 \(CDE\) 中。
根据三角形的三边关系可知:
\(CE<DE+DC\) 并且 \(CE>DC-DE\)。
即 \(b-a>c-d\) 并且 \(b-a<c+d\)。
注意事项
- 因为题目中有表明,所以只有 \(ac\) 和 \(bd\) 是对边。
- 因为 \(a-b\) 有几率出现负数,所以用绝对值函数 abs 来做。
代码
#include <bits/stdc++.h>
using namespace std;
inline int rd(){
int f=1,s=0;char c=getchar();
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
return f*s;
}
inline void print(int x){
if(x<0){putchar('-');print(-x);return;}
if(x>9) print(x/10);
putchar(x%10+'0');
}
int t,a,b,c,d;
int main(){
t=rd();
while(t--){
a=rd();b=rd();c=rd();d=rd();
bool f=0,k=0;
if(a!=c&&b+d>abs(a-c)&&abs(b-d)<abs(a-c))f=1;
else if(b!=d&&a+c>abs(b-d)&&abs(a-c)<abs(b-d))f=1;
if(f==1)cout<<"yes\n";
else cout<<"no\n";
}
return 0;
}
```P10245 Swimming Pool题解
P10245 Swimming Pool题解的更多相关文章
- Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题
A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...
- 【CodeForces 596A】E - 特别水的题5-Wilbur and Swimming Pool
Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...
- Codeforce#331 (Div. 2) A. Wilbur and Swimming Pool(谨以此题来纪念我的愚蠢)
C time limit per test 1 second memory limit per test 256 megabytes input standard input output stand ...
- Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool
A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces--596A--Wilbur and Swimming Pool(数学)
A - Wilbur and Swimming Pool Crawling in process... Crawling failed Time Limit:1000MS Memory ...
- CodeForces 596A Wilbur and Swimming Pool
水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> u ...
- Gym 100637F F. The Pool for Lucky Ones
F. The Pool for Lucky Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- Gym 100637F F. The Pool for Lucky Ones 暴力
F. The Pool for Lucky Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- HPU周赛题目解析
A - Wilbur and Swimming Pool Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- UVALive 6915 Leveling Ground 倍增RMQ
Leveling Ground 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid ...
随机推荐
- [C#] 禁用控制台关闭按钮
禁用控制台关闭按钮 internal class Program { [DllImport("user32.dll", EntryPoint = "FindWindow& ...
- 23ai中的True Cache到底能做啥?
最近,Oracle的产品管理总监在Oracle数据库内幕中介绍了True Cache. 原文链接如下: https://blogs.oracle.com/database/post/introduci ...
- Matlab打印运行进度
在运行matlab程序的过程中,有时候需要实时地掌握程序运行的进度,尤其对于一些耗时较长的循环操作,能够及时地输出运行进度,显得非常有必要. 打印进度条的实现方式就是不断地退格.输出. 退 ...
- 判断是不是ie浏览器 加上ie11
var b_version = navigator.appVersion; var version = b_version.split(";"); var trim_Version ...
- react做购物车的功能
父组件 import React, { Component } from 'react' import Lists from '../components/Lists' export default ...
- UDP 发送两遍对比一致能绝对判定发送过程成功传递完整数据吗
UDP 发送两边对比一致,能确定数据传输无错误吗 对比两条相同数据的MD5 这样做可行吗
- 找不到 .NETFramework,Version=v5.0 的引用程序集。要解决此问题,请为此框架版本安装开发人员工具包(SDK/目标包)或者重新定向应用程序。
找不到 .NETFramework,Version=v5.0 的引用程序集.要解决此问题,请为此框架版本安装开发人员工具包(SDK/目标包)或者重新定向应用程序. visual studio 2019 ...
- Prometheus 聚合查询的两个方案
问题背景 多个 Prometheus 集群或者多个 VictoriaMetrics 集群,在 Grafana 和夜莺里通常需要创建多个不同的数据源,这也就意味着,数据没法聚合查询,比如统一做一下 su ...
- Mysql主机环境导入导出数据
mysql数据库,在主机环境下导出数据为csv文件. 命令:select * into outfile '/mysql/11.csv' from 表; 可能会报错:ERROR 1290 (HY000) ...
- JAVA发送邮件报错: 535 Error: authentication failed, system busy。
解决方法: 1.设置 -> 微信绑定 -> 开启安全登录 -> 生成新密码 2.使用生成的新密码替换邮箱登录密