前言

今天又是爆零的一天。

被同学坑了,还以为四边形的点是按任意序给定的,然后打了一个特别复杂的矩形判断QAQ。

题意简述

按顺序给定一个四边形,求有多少个点在这个四边形的对称轴上。

题解

分情况讨论:

正方形有8个点。

菱形和矩形有4个点。

筝形和等腰梯形有2个点。

剩余的有0个点。

代码

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map> using namespace std; namespace fast_IO{
const int IN_LEN = 10000000, OUT_LEN = 10000000;
char ibuf[IN_LEN], obuf[OUT_LEN], *ih = ibuf + IN_LEN, *oh = obuf, *lastin = ibuf + IN_LEN, *lastout = obuf + OUT_LEN - 1;
inline char getchar_(){return (ih == lastin) && (lastin = (ih = ibuf) + fread(ibuf, 1, IN_LEN, stdin), ih == lastin) ? EOF : *ih++;}
inline void putchar_(const char x){if(oh == lastout) fwrite(obuf, 1, oh - obuf, stdout), oh = obuf; *oh ++= x;}
inline void flush(){fwrite(obuf, 1, oh - obuf, stdout);}
int read(){
int x = 0; int zf = 1; char ch = ' ';
while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar_();
if (ch == '-') zf = -1, ch = getchar_();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar_(); return x * zf;
}
void write(int x){
if (x < 0) putchar_('-'), x = -x;
if (x > 9) write(x / 10);
putchar_(x % 10 + '0');
}
} using namespace fast_IO; #define x first
#define y second
#define Pos pair<double, double> Pos pos[4];
const double EPS = 1e-8; inline bool eql(double a, double b){
return (abs(a - b) <= EPS);
} inline double getDis(Pos a, Pos b){
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
} bool ggdl(int pos1, int pos2, int pos3){
double dis1 = getDis(pos[pos1], pos[pos2]);
double dis2 = getDis(pos[pos2], pos[pos3]);
double dis3 = getDis(pos[pos1], pos[pos3]);
return (eql(dis1 + dis2, dis3) || eql(dis1 + dis3, dis2) || eql(dis2 + dis3, dis1));
} bool isJx(){
double x_c = (pos[0].x + pos[1].x + pos[2].x + pos[3].x) / 4.0;
double y_c = (pos[0].y + pos[1].y + pos[2].y + pos[3].y) / 4.0;
double d1 = getDis(pos[0], make_pair(x_c, y_c));
double d2 = getDis(pos[1], make_pair(x_c, y_c));
double d3 = getDis(pos[2], make_pair(x_c, y_c));
double d4 = getDis(pos[3], make_pair(x_c, y_c));
return (d1 == d2 && d1 == d3 && d1 == d4);
} bool isLx(){
double s12 = getDis(pos[0], pos[1]);
double s14 = getDis(pos[0], pos[3]);
double s23 = getDis(pos[1], pos[2]);
double s34 = getDis(pos[2], pos[3]);
return (s12 == s14 && s14 == s23 && s23 == s34);
} bool isZs(){
bool zs1 = eql(getDis(pos[0], pos[1]), getDis(pos[1], pos[2])) && eql(getDis(pos[0], pos[3]), getDis(pos[3], pos[2]));
bool zs2 = eql(getDis(pos[0], pos[1]), getDis(pos[0], pos[3])) && eql(getDis(pos[2], pos[1]), getDis(pos[2], pos[3]));
return (zs1 || zs2);
} bool tx(){
bool x = eql(getDis(pos[0], pos[1]), getDis(pos[2], pos[3]));
x = x || (eql(getDis(pos[1], pos[2]), getDis(pos[0], pos[3])));
return (eql(getDis(pos[0], pos[2]), getDis(pos[1], pos[3])) && x);
} int main(){
for (int i = 0; i < 4; ++i) pos[i].x = read(), pos[i].y = read();
bool jx = isJx(), lx = isLx();
if (jx && lx)
puts("8");
else if (jx || lx)
puts("4");
else{
if (isZs() || tx())
puts("2");
else
puts("0");
}
return 0;
}

[517]Kite 题解的更多相关文章

  1. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】

    A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...

  2. URAL 1963 Kite 计算几何

    Kite 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/C Description Vova bought a kite con ...

  3. LeetCode All in One题解汇总(持续更新中...)

    突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...

  4. 题解【洛谷P2615】[NOIP2015]神奇的幻方

    题目描述 幻方是一种很神奇的 \(N \times N\) 矩阵:它由数字 \(1,2,3,\cdots \cdots ,N \times N\) 构成,且每行.每列及两条对角线上的数字之和都相同. ...

  5. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  6. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  7. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  8. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  9. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

随机推荐

  1. adb 性能测试(内存)

    内存测试: 1.使用数据线将手机与电脑连接: 2.手机打开待测APP,即打开进程: 3.打开cmd命令,获取设备列表:输入adb devices; 4.进入该设备的shell环境,输入:adb -s  ...

  2. 如何用katalon录制回放一个web UI测试—— katalon学习笔记(四)

    ,首先打开katanlon,进入到katalon主界面,选择点击file->new->project ,在创建新项目弹出框中Name输入项输入项目的名称:Type选择web,也就是你要测试 ...

  3. YARN日志聚合相关参数配置

    日志聚合是YARN提供的日志中央化管理功能,它能将运行完成的Container/任务日志上传到HDFS上,从而减轻NodeManager负载,且提供一个中央化存储和分析机制.默认情况下,Contain ...

  4. 应用安全 - Web框架 - Apache Flink - 漏洞汇总

    SSV ID:SSV-98101 -- 类型: 文件上传导致远程代码执行   flink下载: https://www.apache.org/dyn/closer.lua/flink/flink-1. ...

  5. JS中值类型和引用类型

    一.值类型 例子: var a=10; var b=a; a=20; console.log(b); 例子中,将a的值赋给了b,b=10,然后改变a的值不会影响b的值,a和b是独立的两份,互不影响. ...

  6. CCF1078奇怪的电梯

    这是一道dfs搜索题.(noi的题库测试数据有些水) 已知每一层的步数,有两个方向(上下),求解到达终点的最少操作数.拿到这个题就发现是一个Dfs,于是便套了模板写代码.Wa了三次才AC.核心是:1. ...

  7. P2523 [HAOI2011]Problem c

    传送门 先考虑如何判断无解,设 $sum[i]$ 表示确定的人中,编号大于 $i$ 的人的人数 如果 $sum[i]>n-i+1$ 则无解,进一步考虑设 $f[i][j]$ 表示当前确定完编号大 ...

  8. wordpress开发的一些积累

    wordpress 攒知识点 记录开发 wordpress 的一些技能点,以备不时之需 短代码 Shortcode 虽然很多插件都是提供,直接在代码中插入类似[Shortcode] 便可以生效,但是很 ...

  9. html中的dl,dt,dd标签

    html <dl> <dt> <dd>是一组合标签,使用了dt dd最外层就必须使用dl包裹,此组合标签我们也又叫表格标签,与table表格类似组合标签,故名我们也 ...

  10. locale - 地域定义文件的描述

    描述 地域 定义文件含有 localedef(1) 命令所需的全部信息. 定义文件由几个小节组成, 一个小节详细地描述地域的一个范畴. 语法 地域定义文件以一个包含有如下关键字的文件头开头: < ...