C. Kite

Time Limit: 1000ms   Case Time Limit: 1000ms   Memory Limit: 65536KB

 
Vova bought a kite construction kit in a market in Guangzhou. The next day the weather was good and he decided to make the kite and fly it. Manufacturing instructions, of course, were only in Chinese, so Vova decided that he can do without it. After a little tinkering, he constructed a kite in the form of a flat quadrangle and only needed to stick a tail to it.
And then Vova had to think about that: to what point of the quadrangle's border should he stick the kite tail? Intuition told him that in order to make the kite fly steadily, its tail should lie on some axis of symmetry of the quadrangle. On the left you can see two figures of stable kites, and on the right you can see two figures of unstable kites.
How many points on the quadrangle border are there such that if we stick a tail to them, we get a stable kite?
 

Input

The four lines contain the coordinates of the quadrangle's vertices in a circular order. All coordinates are integers, their absolute values don't exceed 1 000. No three consecutive quadrangle vertices lie on the same line. The opposite sides of the quadrangle do not intersect.
 

Output

Print the number of points on the quadrangle border where you can attach the kite.
 

Sample Input

input output
0 0
1 2
2 2
2 1
2
0 0
2 1
2 2
0 2
0
 

Hint

The axis of symmetry of a flat figure is a straight line lying in the figure plane and dividing the figure to the two halves that are each other's mirror image.
 
 
 

题意:求四边形,镜面对称的点;

思路:首先镜面对称,那么点的个数就是一定是偶数倍的。然后既然是镜面对称,那么他的投影点和点的镜面的距离一定是相等的;

转载请注明出处:寻找&星空の孩子

题目链接:Kite:http://www.bnuoj.com/bnuoj/problem_show.php?pid=33563

so......

 #include<cstdio>
#include<cmath>
#include<iostream>
#define PI acos(-1.0)
using namespace std; struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y){}//构造函数,方便代码编写
}; typedef Point Vector;//Vector只是Point的别名 //向量+向量=向量; 向量+点=点
Vector operator + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);} //点-点=向量
Vector operator - (Point A,Point B){return Vector(A.x-B.x,A.y-B.y);} //向量*数=向量
Vector operator * (Vector A,double p){return Vector(A.x*p,A.y*p);} //向量/数=向量
Vector operator / (Vector A,double p){return Vector(A.x/p,A.y/p);} //
bool operator < (const Point& a,const Point& b){return a.x<b.x||(a.x==b.x && a.y<b.y);} //
const double eps = 1e-;
//三态函数
int dcmp(double x){if(fabs(x)<eps)return ;else return x < ? - : ;}
//相等
bool operator == (const Point& a,const Point& b){return dcmp(a.x-b.x)== && dcmp(a.y-b.y)==;} //点积 x1*x2+y1*y2
//向量垂直点积为0;
//利用点积,求向量的夹角和长度;
double Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}
double length(Vector A){return sqrt(Dot(A,A));}
double Angle(Vector A,Vector B){return acos(Dot(A,B)/length(A)/length(B));} //叉积 x1*y2-x2*y1
//向量共线叉积为0;
//叉积为三角形有向面积的2倍
//已知三点求三角形面积
double Cross(Vector A,Vector B){return A.x*B.y-B.x*A.y;}
double Area2(Point A,Point B,Point C){return Cross(B-A,C-A);} double DistanceToLine(Point P,Point A,Point B)
{
Vector v1=B-A, v2=P-A;
return fabs(Cross(v1,v2))/length(v1);//如果不取绝对值,得到的是有向距离;
} Point GetLineProjection(Point P,Point A,Point B)
{
Vector v=B-A;
return A+v*(Dot(v,P-A)/Dot(v,v));
} Point div(Point &A,Point &B)
{
Point E;
E.x=(A.x+B.x)/;
E.y=(A.y+B.y)/;
return E;
}
int main()
{
Point A,B,C,D;
Point AB,BC,CD,DA;
while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y,&D.x,&D.y)!=EOF)
{
AB=div(A,B);
BC=div(B,C);
CD=div(C,D);
DA=div(D,A); // printf("%lf%lf\n%lf%lf\n%lf%lf\n%lf%lf\n",A.x,A.y,B.x,B.y,C.x,C.y,D.x,D.y);
int cnt=;
Point P1,P2,P3,P4;
double x1,x2,x3,x4;
//A--C
P1=GetLineProjection(B,A,C);
P2=GetLineProjection(D,A,C);
x1=DistanceToLine(B,A,C);
x2=DistanceToLine(D,A,C);
if(P1==P2&&x1==x2) cnt+=;
// if(Area2(A,B,C)==Area2(A,D,C)) cnt+=2; //B--D
P1=GetLineProjection(A,B,D);
P2=GetLineProjection(C,B,D);
x1=DistanceToLine(A,B,D);
x2=DistanceToLine(C,B,D);
if(P1==P2&&x1==x2) cnt+=;
// if(Area2(B,A,D)==Area2(B,C,D)) cnt+=2; //BC--DA
P1=GetLineProjection(A,BC,DA);
P2=GetLineProjection(D,BC,DA);
P3=GetLineProjection(B,BC,DA);
P4=GetLineProjection(C,BC,DA);
x1=DistanceToLine(A,BC,DA);
x2=DistanceToLine(D,BC,DA);
x3=DistanceToLine(B,BC,DA);
x4=DistanceToLine(C,BC,DA);
if(P1==P2&&P3==P4&&x1==x2&&x3==x4) cnt+=;
// if(Area2(D,DA,BC)+Area2(D,BC,C)==Area2(A,DA,BC)+Area2(A,BC,B)) cnt+=2; //AB--CD
P1=GetLineProjection(A,AB,CD);
P2=GetLineProjection(B,AB,CD);
P3=GetLineProjection(C,AB,CD);
P4=GetLineProjection(D,AB,CD);
x1=DistanceToLine(A,AB,CD);
x2=DistanceToLine(B,AB,CD);
x3=DistanceToLine(C,AB,CD);
x4=DistanceToLine(D,AB,CD);
if(P1==P2&&P3==P4&&x1==x2&&x3==x4) cnt+=;
// if(Area2(A,AB,CD)+Area2(A,CD,D)==Area2(B,AB,CD)+Area2(B,CD,C)) cnt+=2; printf("%d\n",cnt);
}
return ;
}
 
 
 
 
 
 
 
 
 

Kite(几何+镜面对称)的更多相关文章

  1. C - Kite URAL - 1963 (几何+四边形判断对称轴)

    题目链接:https://cn.vjudge.net/problem/URAL-1963 题目大意:给你一个四边形的n个点,让你判断对称点的个数(对称轴的个数*2). 具体思路:感谢qyn的讲解,具体 ...

  2. 关于Three.js基本几何形状之SphereGeometry球体学习

    一.有关球体SphereGeometry构造函数参数说明 <1>.SphereGeometry(radius, widthSegments, heightSegments, phiStar ...

  3. 几何服务,cut功能测试

    关于几何服务 几何服务用于辅助应用程序执行各种几何计算,如缓冲区.简化.面积和长度计算以及投影.在 ArcGIS Server 管理器中启动几何服务之后,您才能够在应用程序开发过程中使用该服务. 问题 ...

  4. 几何服务,cut功能,输入要素target(修改后)内容。

    几何服务,cut功能测试,输入要素target(修改后)内容. {"displayFieldName":"","fieldAliases": ...

  5. 几何服务,cut功能,输入要素target(修改前)内容。

    几何服务,cut功能测试,输入要素target(修改前)内容. {"geometryType":"esriGeometryPolyline","geo ...

  6. 如何让你的UWP应用程序无缝调用几何作图

    有时候需要编辑一些几何图形,如三角形,圆锥曲线等,在UWP应用中加入这些几何作图功能是件费时间又很难做好的事.其实Windows 10 应用商店中已有一些专业的几何作图工具了,那么能借来一用吗?答案是 ...

  7. poj 2031Building a Space Station(几何判断+Kruskal最小生成树)

    /* 最小生成树 + 几何判断 Kruskal 球心之间的距离 - 两个球的半径 < 0 则说明是覆盖的!此时的距离按照0计算 */ #include<iostream> #incl ...

  8. NOIP2002矩形覆盖[几何DFS]

    题目描述 在平面上有 n 个点(n <= 50),每个点用一对整数坐标表示.例如:当 n=4 时,4个点的坐标分另为:p1(1,1),p2(2,2),p3(3,6),P4(0,7),见图一. 这 ...

  9. DOM 元素节点几何量与滚动几何量

    当在 Web 浏览器中查看 HTML 文档时,DOM 节点被解析,并被渲染成盒模型(如下图),有时我们需要知道一些信息,比如盒模型的大小,盒模型在浏览器中的位置等等,本文我们就来详细了解下元素节点的几 ...

随机推荐

  1. 我的第一个python爬虫

    我的第一个爬虫,哈哈,纯面向过程 实现目标: 1.抓取本地conf文件,其中的URL地址,然后抓取视频名称以及对应的下载URL 2.抓取URL会单独写在本地路径下,以便复制粘贴下载 废话补多少,代码实 ...

  2. httphandler httpmodule一些个人理解

    asp.net 对于http请求需要走一个管道就行一层一层的过滤:比如身份验证,根据请求的资源不同分发给具体哪个dll来处理 这些管道中就是httpmodule.所以我们自己写的httpmodule实 ...

  3. C#顺序表 & 单向链表(无头)

    C# 顺序表 非常标准的顺序表结构,等同于C#中的List<T>,但是List<T>在排错查询和数据结构替换上存在缺陷,一些情况会考虑使用自己定义的数据结构 1.优化方向 下表 ...

  4. oracle utl_http 访问https类型

    https://oracle-base.com/articles/misc/utl_http-and-ssl http://blog.whitehorses.nl/2010/05/27/access- ...

  5. 统计C/C++代码行数

    近日在写一个统计项目中C/C++文件(后缀名:C/CPP/CC/H/HPP文件)代码行数的小程序.给定包含C/C++代码的目录,统计目录里所有C/C++文件的总代码行数.有效代码行数.注释行数.空白行 ...

  6. Thinking in Java from Chapter 7

    From Thinking in Java 4th Edition final 1. 对于基本类型,final使数值恒定不变 2. 对于对象引用,final使引用恒定不变,即不能指向别的对象,但指向的 ...

  7. InnoDB体系架构(二)内存

    InnoDB体系架构(二)内存 上篇文章 InnoDB体系架构(一)后台线程 介绍了MySQL InnoDB存储引擎后台线程:Master Thread.IO Thread.Purge Thread. ...

  8. Java中的引用传递和值传递

    Java中的引用传递和值传递 关于Java的引用传递和值传递,在听了老师讲解后,还是没有弄清楚是怎么一回事,于是查了资料,所以在这里与大家分享,有不对的地方,欢迎大家留言. java中是没有指针的,j ...

  9. Java 8 停止维护,Java 9 难产,IDEA 2018 发布,还有……

    祝大家五一劳动节快乐,工作顺利! 又到了总结上个月干货的时候了,这个月我们带来了各种Java技术干货,各种送书抽奖福利,各种面试题分享,各种最新动态资讯等. 5.1重磅活动 | 区块链免费送书 &am ...

  10. Python常用模块——json & pickle

    序列化模块 1.什么是序列化-------将原本的字典,列表等对象转换成一个字符串的过程就叫做序列化 2.序列化的目的 1.以某种存储形式使自定义对象持久化 2.将对象从一个地方传递到另一个地方 3. ...