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
  1. 0 0
  2. 1 2
  3. 2 2
  4. 2 1
  1. 2
  1. 0 0
  2. 2 1
  3. 2 2
  4. 0 2
  1. 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......

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<iostream>
  4. #define PI acos(-1.0)
  5. using namespace std;
  6.  
  7. struct Point
  8. {
  9. double x,y;
  10. Point(double x=,double y=):x(x),y(y){}//构造函数,方便代码编写
  11. };
  12.  
  13. typedef Point Vector;//Vector只是Point的别名
  14.  
  15. //向量+向量=向量; 向量+点=点
  16. Vector operator + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
  17.  
  18. //点-点=向量
  19. Vector operator - (Point A,Point B){return Vector(A.x-B.x,A.y-B.y);}
  20.  
  21. //向量*数=向量
  22. Vector operator * (Vector A,double p){return Vector(A.x*p,A.y*p);}
  23.  
  24. //向量/数=向量
  25. Vector operator / (Vector A,double p){return Vector(A.x/p,A.y/p);}
  26.  
  27. //
  28. bool operator < (const Point& a,const Point& b){return a.x<b.x||(a.x==b.x && a.y<b.y);}
  29.  
  30. //
  31. const double eps = 1e-;
  32. //三态函数
  33. int dcmp(double x){if(fabs(x)<eps)return ;else return x < ? - : ;}
  34. //相等
  35. bool operator == (const Point& a,const Point& b){return dcmp(a.x-b.x)== && dcmp(a.y-b.y)==;}
  36.  
  37. //点积 x1*x2+y1*y2
  38. //向量垂直点积为0;
  39. //利用点积,求向量的夹角和长度;
  40. double Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}
  41. double length(Vector A){return sqrt(Dot(A,A));}
  42. double Angle(Vector A,Vector B){return acos(Dot(A,B)/length(A)/length(B));}
  43.  
  44. //叉积 x1*y2-x2*y1
  45. //向量共线叉积为0;
  46. //叉积为三角形有向面积的2倍
  47. //已知三点求三角形面积
  48. double Cross(Vector A,Vector B){return A.x*B.y-B.x*A.y;}
  49. double Area2(Point A,Point B,Point C){return Cross(B-A,C-A);}
  50.  
  51. double DistanceToLine(Point P,Point A,Point B)
  52. {
  53. Vector v1=B-A, v2=P-A;
  54. return fabs(Cross(v1,v2))/length(v1);//如果不取绝对值,得到的是有向距离;
  55. }
  56.  
  57. Point GetLineProjection(Point P,Point A,Point B)
  58. {
  59. Vector v=B-A;
  60. return A+v*(Dot(v,P-A)/Dot(v,v));
  61. }
  62.  
  63. Point div(Point &A,Point &B)
  64. {
  65. Point E;
  66. E.x=(A.x+B.x)/;
  67. E.y=(A.y+B.y)/;
  68. return E;
  69. }
  70. int main()
  71. {
  72. Point A,B,C,D;
  73. Point AB,BC,CD,DA;
  74. 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)
  75. {
  76. AB=div(A,B);
  77. BC=div(B,C);
  78. CD=div(C,D);
  79. DA=div(D,A);
  80.  
  81. // 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);
  82. int cnt=;
  83. Point P1,P2,P3,P4;
  84. double x1,x2,x3,x4;
  85. //A--C
  86. P1=GetLineProjection(B,A,C);
  87. P2=GetLineProjection(D,A,C);
  88. x1=DistanceToLine(B,A,C);
  89. x2=DistanceToLine(D,A,C);
  90. if(P1==P2&&x1==x2) cnt+=;
  91. // if(Area2(A,B,C)==Area2(A,D,C)) cnt+=2;
  92.  
  93. //B--D
  94. P1=GetLineProjection(A,B,D);
  95. P2=GetLineProjection(C,B,D);
  96. x1=DistanceToLine(A,B,D);
  97. x2=DistanceToLine(C,B,D);
  98. if(P1==P2&&x1==x2) cnt+=;
  99. // if(Area2(B,A,D)==Area2(B,C,D)) cnt+=2;
  100.  
  101. //BC--DA
  102. P1=GetLineProjection(A,BC,DA);
  103. P2=GetLineProjection(D,BC,DA);
  104. P3=GetLineProjection(B,BC,DA);
  105. P4=GetLineProjection(C,BC,DA);
  106. x1=DistanceToLine(A,BC,DA);
  107. x2=DistanceToLine(D,BC,DA);
  108. x3=DistanceToLine(B,BC,DA);
  109. x4=DistanceToLine(C,BC,DA);
  110. if(P1==P2&&P3==P4&&x1==x2&&x3==x4) cnt+=;
  111. // if(Area2(D,DA,BC)+Area2(D,BC,C)==Area2(A,DA,BC)+Area2(A,BC,B)) cnt+=2;
  112.  
  113. //AB--CD
  114. P1=GetLineProjection(A,AB,CD);
  115. P2=GetLineProjection(B,AB,CD);
  116. P3=GetLineProjection(C,AB,CD);
  117. P4=GetLineProjection(D,AB,CD);
  118. x1=DistanceToLine(A,AB,CD);
  119. x2=DistanceToLine(B,AB,CD);
  120. x3=DistanceToLine(C,AB,CD);
  121. x4=DistanceToLine(D,AB,CD);
  122. if(P1==P2&&P3==P4&&x1==x2&&x3==x4) cnt+=;
  123. // if(Area2(A,AB,CD)+Area2(A,CD,D)==Area2(B,AB,CD)+Area2(B,CD,C)) cnt+=2;
  124.  
  125. printf("%d\n",cnt);
  126. }
  127. return ;
  128. }
 
 
 
 
 
 
 
 
 

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. windows安装mongodb及相关命令

      - 安装   解压: mongodb-win32-x86_64-2008plus-ssl-3.6.4.7z 将文件夹改名为mongodb 移动文件到指定目录下,如: C:\python\soft ...

  2. tar打包如何不打包某一个文件夹(排除某些文件夹)

    tar打包如何不打包某一个文件夹(排除某些文件夹) 问题描述: 最近想备份一下Tomcat运行的的功能文件,以防特殊情况的发生.但是在实际操作的过程中发现,可能是由于Unix/Linux版本太老的原因 ...

  3. Android-Java-静态成员变量&成员变量&局部变量(内存图&回收机制)

    静态成员变量(回收机制) StaticDemo 和 MyDemo package android.java.oop13; class MyDemo { /** * 定义一个静态变量 */ public ...

  4. Buffer cache hit ratio性能计数器真的可以作为SQL Server 内存瓶颈的判断指标吗?

    SQL Server中对于Buffer cache hit ratio的理解: Buffer cache hit ratio官方是这么解释的:“指示在缓冲区高速缓存中找到而不需要从磁盘中读取的页的百分 ...

  5. Nhibernate入门篇连接Sqlserver的增删查改

    第一步:创建数据库 create table Emp( EmpId int primary key identity, EmpName ), EmpDate date ) 第二步:去官网下载:http ...

  6. 如何使用react-redux——傻瓜版

    概述 之前看redux官方文档真是看得一脸懵逼,现在自认为会用了,于是来总结一下用法,供以后开发时参考,相信对其他人也有用. 不得不说,用了redux之后感觉挺爽的,有如下优点: 组件大多是函数组件非 ...

  7. 解决element-ui upload组件报错 Avoid using non-primitive value as key, use string/number value instead

    到底是啥错呢,就是要求你的key必须是string或者number类型 那么解决就是找到这个报错的key(在node_modules/element-ui/lib/element-ui.common. ...

  8. webrtc vad小bug

    当channel为5的时候offset为80,再进行下面的操作smallest_values[j + 1]将会越出数组的限界到”第97个“:应该将下图的16改为15 low_value_vector数 ...

  9. Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded

    1 开发环境 Ubuntu16.04(64bit) 2 错误描述 安装好Vim的TagList插件后,打开Vim提示: 3 解决方法 根据参考资料[1]的提示,可知那是因为当前系统没有安装ctags导 ...

  10. google的android工具常用下载路径

    android的bug工具在网上搜的时候,经常被索引到垃圾网站,今天找到了一个网站下载android工具 都是最新的,十分不错,就做个分享吧. Google 提供了 Windows.macOS 以及 ...