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 ...
随机推荐
- Supervisor 守护进程管理工具
引言 Supervisor 是基于 Python 编程语言开发的一套通用的进程管理程序,它是通过 fork/exec 的方式把需要管理的进程作为子进程来管理. 安装 pip3 安装 superviso ...
- navicat premium 15 下载和激活
Navicat Premium 15 下载地址 链接:https://pan.baidu.com/s/1bL-M3-hkEa4M-547giVjYQ?pwd=1107 推荐安装参考地址:https:/ ...
- Python爬图片
1 import requests 2 from lxml import etree 3 4 header = { 5 "user-agent": "Mozilla/5. ...
- CSS——float浮动属性
流动布局 流动模型(Flow),即文档流,浏览器打开HTML网页时,从上往下,从左往右,逐一加载. 在正常情况下,HTML元素都会根据文档流来分布网页内容的. 文档流有2大特征: ① 块状元素会随着浏 ...
- Android 13 - Media框架(23)- ACodecBufferChannel
关注公众号免费阅读全文,进入音视频开发技术分享群! 这一节我们将了解 ACodecBufferChannel 上一节我们了解到input buffer 和 output buffer 是如何分配的了, ...
- C#调用微软api文本转语音
目录 1.注册微软云服务,搭建文本转语音标准应用(每月500万字免费好像) 2.Visual studio使用nuget给程序安装Microsoft.CognitiveServices.Speech框 ...
- const与指针的组合
① const int *p; //指向一个整型常量的指针,p可变,p指向的对象不可变. ② int const *p; //同上. ③ int * const p; //p不可变,p指向的对象可变( ...
- 如何保留 Excel 表头和第一行数据并追加 CSV 数据
准备工作 在开始之前,确保你的 Python 环境中已经安装了 openpyxl 和 pandas 库.可以使用以下命令进行安装: pip install openpyxl pandas 第一步:编写 ...
- Linux 提权-Cron Jobs
本文通过 Google 翻译 Cron Jobs – Linux Privilege Escalation - Juggernaut-Sec 这篇文章所产生,本人仅是对机器翻译中部分表达别扭的字词进行 ...
- jquery的全局函数 多库并存
// jQuery的全局函数 , 也称钩子函数 // 所谓的钩子函数 是 与 其他函数绑定的函数 // 作用是 监听 函数的执行 当函数执行到某个状态时 ...