Kite

题目连接:

http://acm.hust.edu.cn/vjudge/contest/123332#problem/C

Description

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.

Problem illustration

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

0 0

1 2

2 2

2 1

Sample Output

2

Hint

题意

给你个四边形,问你有多少个点在这个四边形的对称轴上

题解:

在对称轴上的点只有四边形的端点,以及端点之间的中点。

把这些点压进去,然后暴力去判断就好了。

代码

#include<bits/stdc++.h>
using namespace std;
const double INF = 1E200;
const double EP = 1E-6 ;
const int MAXV = 300 ;
const double PI = 3.14159265;
int vis[100];
/* 基本几何结构 */
struct POINT
{
double x;
double y;
POINT(double a=0, double b=0) { x=a; y=b;} //constructor
};
struct LINESEG
{
POINT s;
POINT e;
LINESEG(POINT a, POINT b) { s=a; e=b;}
LINESEG() { }
};
struct LINE // 直线的解析方程 a*x+b*y+c=0 为统一表示,约定 a >= 0
{
double a;
double b;
double c;
LINE(double d1=1, double d2=-1, double d3=0) {a=d1; b=d2; c=d3;}
};
double dist(POINT p1,POINT p2) // 返回两点之间欧氏距离
{
return( sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ) );
}
double multiply(POINT sp,POINT ep,POINT op)
{
return((sp.x-op.x)*(ep.y-op.y)-(ep.x-op.x)*(sp.y-op.y));
}
double ptoldist(POINT p,LINESEG l)
{
return abs(multiply(p,l.e,l.s))/dist(l.s,l.e);
}
POINT p[100];
POINT tmp[10];
int main(){
for(int i=0;i<4;i++){
scanf("%lf%lf",&tmp[i].x,&tmp[i].y);
}
tmp[4]=tmp[0];
int cnt = 0;
for(int i=1;i<=4;i++){
p[cnt++]=tmp[i-1];
p[cnt].x=(tmp[i-1].x+tmp[i].x)/2.0;
p[cnt++].y=(tmp[i-1].y+tmp[i].y)/2.0;
}
int ans = 0;
int n = cnt;
int k = n/2;
for(int i=0;i+k<n;i++){
int flag = 0;
for(int j=0;j<=n;j++){
int a1 = (i+j+n)%n;
int a2 = (i-j+n)%n;
if(fabs(ptoldist(p[a1],LINESEG(p[i],p[i+k]))-ptoldist(p[a2],LINESEG(p[i],p[i+k])))>EP)
{
flag = 1;
break;
}
POINT c = POINT((p[a1].x+p[a2].x)/2.0,(p[a1].y+p[a2].y)/2.0);
if(ptoldist(c,LINESEG(p[i],p[i+k]))>EP){
flag = 1;
break;
}
double x1 = p[i].x - p[i+k].x;
double y1 = p[i].y - p[i+k].y;
double x2 = p[a1].x - p[a2].x;
double y2 = p[a1].y - p[a2].y; if(fabs(x1*x2+y1*y2)>EP){
flag = 1;
break;
}
}
if(flag==0)ans+=2;
}
cout<<ans<<endl;
}

URAL 1963 Kite 计算几何的更多相关文章

  1. URAL 1963 Kite 四边形求对称轴数

    题目链接: http://acm.timus.ru/problem.aspx?space=1&num=1963 题意,顺时针或逆时针给定4个坐标,问对称轴有几条,输出(对称轴数*2) 对于一条 ...

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

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

  3. Ural 2036. Intersect Until You're Sick of It 计算几何

    2036. Intersect Until You're Sick of It 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2036 ...

  4. URAL 1775 B - Space Bowling 计算几何

    B - Space BowlingTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  5. Ural 1046 Geometrical Dreams(解方程+计算几何)

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1046 参考博客:http://hi.baidu.com/cloudygoose/item ...

  6. URAL 2099 Space Invader题解 (计算几何)

    啥也不说了,直接看图吧…… 代码如下: #include<stdio.h> #include<iostream> #include<math.h> using na ...

  7. URAL 1966 Cycling Roads 计算几何

    Cycling Roads 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/F Description When Vova was ...

  8. 【计算几何】URAL - 2101 - Knight's Shield

    Little Peter Ivanov likes to play knights. Or musketeers. Or samurai. It depends on his mood. For pa ...

  9. URAL 1750 Pakhom and the Gully 计算几何+floyd

    题目链接:点击打开链接 gg.. . #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cs ...

随机推荐

  1. PHP 文件加密Zend Guard Loader 学习和使用(如何安装ioncube扩展对PHP代码加密)

    一.大体流程图 二.PHP 项目文件加密 下表列出了Zend产品中的PHP版本及其内部API版本和Zend产品版本. 如何加密请往后看 三.如何使用 第一步:确认当前环境 Amai Phalcon 前 ...

  2. 内存对齐与ANSI C中struct型数据的内存布局 【转】

    转自:http://blog.chinaunix.net/uid-25909619-id-3032209.html 当在C中定义了一个结构类型时,它的大小是否等于各字段(field)大小之和?编译器将 ...

  3. Python学习一|anaconda的安装问题以及Python语言的特点

    安装时遇到的问题 安装anaconda3.0到D盘之后,配置好两个环境变量:D:\anaconda和D:\anaconda\Scripts.发现在命令行中执行python指令可以,但conda指令却是 ...

  4. 基于Apache在本地配置多个虚拟主机站点

    简单的说,打开httpd.conf 在最后加入如下内容: <VirtualHost 127.0.0.2:80>    DocumentRoot d:/AppServ/www2    Ser ...

  5. list 转换成dictionary,并统计词频

    >>> from collections import Counter>>> Counter(['apple','red','apple','red','red', ...

  6. LeetCode(19):删除链表的倒数第N个节点

    Medium! 题目描述: 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点. 示例: 给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了 ...

  7. js 获取json对象的Key、value(js遍历json对象的key和value)

    <script type="text/javascript"> getJson('age'); function getJson(key){ "," ...

  8. Java编程的逻辑 (56) - 文件概述

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  9. springcloud hystrix 部分参数整理

    hystrix.command.default和hystrix.threadpool.default中的default为默认CommandKey Command Properties Executio ...

  10. 【LOJ】#2183. 「SDOI2015」序列统计

    题解 这个乘积比较麻烦,转换成原根的指数乘法就相当于指数加和了,可以NTT优化 注意判掉0 代码 #include <bits/stdc++.h> #define fi first #de ...