PAT T1011 Cut Rectangles
大模拟题,按要求建立多边形,先定位斜边的位置,再分类讨论~
#include<bits/stdc++.h>
using namespace std;
const int maxn=;
struct node {
double x,y;
}Node[][maxn];
double distance (node a,node b) {
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int isXiebian (node a,node b) {
if (a.x!=b.x&&a.y!=b.y) return ;
return ;
}
double angle (node a,node b) {
return fabs(a.x-b.x)/fabs(a.y-b.y);
}
vector<double> edge[];
int main () {
int T;
scanf ("%d",&T);
int k1,k2;
while (T--) {
edge[].clear();edge[].clear();
scanf ("%d",&k1);
for (int i=;i<k1;i++) scanf ("%lf %lf",&Node[][i].x,&Node[][i].y);
scanf ("%d",&k2);
for (int i=;i<k2;i++) scanf ("%lf %lf",&Node[][i].x,&Node[][i].y);
double xie1=,xie2=,cnt1=,cnt2=,angle1,angle2,p1,p2;
for (int i=;i<k1;i++) {
int j=i<k1-?i+:;
if (isXiebian(Node[][i],Node[][j])) xie1=distance(Node[][i],Node[][j]),cnt1++,
angle1=angle(Node[][i],Node[][j]);
edge[].push_back(distance(Node[][i],Node[][j]));
}
for (int i=;i<k2;i++) {
int j=i<k2-?i+:;
if (isXiebian(Node[][i],Node[][j])) xie2=distance(Node[][i],Node[][j]),cnt2++,
angle2=angle(Node[][i],Node[][j]);
edge[].push_back(distance(Node[][i],Node[][j]));
}
if (k1+k2>||k1+k2<) printf ("NO\n");
else if (xie1==xie2&&cnt1==&&cnt2==) {
if ((angle1==angle2||angle1*angle2==)&&(k1!=||k2!=)) printf ("YES\n");
else if (k1==&&k2==) {
double z1=p1<k1-?p1+:p1+-k1;
double z2=p2<k2-?p2+:p2+-k2;
double z3=p1<k1-?p1+:;
double z4=p1>?p1-:k1-;
double z5=p2<k2-?p2+:;
double z6=p2>?p2-:k2-;
if (edge[][z1]==edge[][z2]&&(edge[][z3]+edge[][z5]==edge[][z4]+edge[][z6]||
edge[][z3]+edge[][z6]==edge[][z4]+edge[][z5])) printf ("YES\n");
else printf ("NO\n");
}
else printf ("NO\n");
}
else if (xie1==&&xie2==&&k1==&&k2==) {
for (int i=;i<k1;i++) {
for (int k=;k<k2;k++)
if (edge[][i]==edge[][k]) cnt1++;
}
if (cnt1==||cnt1==) printf ("YES\n");
else printf ("NO\n");
}
else printf ("NO\n");
}
return ;
}
PAT T1011 Cut Rectangles的更多相关文章
- PAT 1132 Cut Integer
1132 Cut Integer (20 分) Cutting an integer means to cut a K digits lone integer Z into two integer ...
- PAT A1132 Cut Integer (20 分)——数学题
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long int ...
- PAT 1132 Cut Integer[简单]
1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...
- pat 1132 Cut Integer(20 分)
1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...
- PAT (Advanced Level) Practice(更新中)
Source: PAT (Advanced Level) Practice Reference: [1]胡凡,曾磊.算法笔记[M].机械工业出版社.2016.7 Outline: 基础数据结构: 线性 ...
- PAT_A1132#Cut Integer
Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone in ...
- PAT 甲级 1132 Cut Integer
https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...
- PAT甲级——A1132 Cut Integer
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long int ...
- PAT Advanced 1132 Cut Integer (20) [数学问题-简单数学]
题目 Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long ...
随机推荐
- 吴裕雄 python 机器学习——KNN回归KNeighborsRegressor模型
import numpy as np import matplotlib.pyplot as plt from sklearn import neighbors, datasets from skle ...
- Centos6.10-FastDFS-存储器Http配置
Centos610系列配置 1.准备配置 cd /opt/download/fastdfs-master/confcp http.conf /etc/fdfs/http.confcp mime.typ ...
- (原创)SoapUI学习(2)- POST请求
1.新建Project,右键Projects->New REST Project,可以不填直接点击OK,之后通过rename重命名.(如果这里添加URL,则直接达到第三步的图) 2.右键新建的工 ...
- GO学习之 安装Go语言及搭建Go语言开发环境
一.下载 1.下载地址 Go官网下载地址:https://golang.org/dl/ Go官方镜像站(推荐):https://golang.google.cn/dl/ 2.版本的选择 Windows ...
- Mysql主从复制,双主热备
Mysql主从复制: 主从复制: 主机准备工作: 开启bin.Log 注意:server-id 是唯一的值 重启mysql:service mysql restart 查看是否开启成功: 查看当前状 ...
- 【转】 WordPress数据库及各表结构分析
默认WordPress一共有以下11个表.这里加上了默认的表前缀 wp_ . wp_commentmeta:存储评论的元数据wp_comments:存储评论wp_links:存储友情链接(Blogro ...
- Django--模型管理器
参考https://blog.csdn.net/qq_34788903/article/details/87889451 可参考视频 : https://www.bilibili.com/video ...
- RT_THREAD之组件学习
CmBacktrace (Cortex Microcontroller Backtrace)是一款针对 ARM Cortex-M 系列 MCU 的错误代码自动追踪.定位,错误原因自动分析的开源库.支持 ...
- YouTube为创作者提供了更多赚钱的途径
编辑 | 于斌 出品 | 于见(mpyujian) 大家提到YouTube可能还有些陌生,只是听说过,但因为一些原因并没有实际应用过,但其实YouTube就是设立在美国的一个视频分享网站,让使用者上载 ...
- Mysql架构、复制类型、复制功能介绍
1.1 常见的几种主从架构 一主一从 一主多从 多主一从 双主互备 1.2 主从复制功能 1)实时灾备 2)读写分离 3)高可用 4)从库数据统计 5)从库数据备份 6)平滑升级 1.3 三种复制方式 ...