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. bzoj千题计划198:bzoj1084: [SCOI2005]最大子矩阵

    http://www.lydsy.com/JudgeOnline/problem.php?id=1084 m=1: dp[i][j] 前i个数,选了j个矩阵的最大和 第i个不选:由dp[i-1][j] ...

  2. [转载]win7休眠后网络断开怎么办?如何设置?

    http://jingyan.baidu.com/article/8065f87fc87d0423312498af.html 有时会遇到在Windows7系统休眠模式下会自动断开网络连接,唤醒系统也是 ...

  3. Windows bat 学习(初级)

    http://steve-jansen.github.io/guides/windows-batch-scripting/part-1-getting-started.html 注释:REM 或 :: ...

  4. shape-outside 矩形之外的另一种思路

    http://docs.webplatform.org/wiki/css/properties/shape-outside

  5. HDU 4608 I-number 2013 Multi-University Training Contest 1 1009题

    题目大意:输入一个数x,求一个对应的y,这个y满足以下条件,第一,y>x,第二,y 的各位数之和能被10整除,第三,求满足前两个条件的最小的y. 解题报告:一个模拟题,比赛的时候确没过,感觉这题 ...

  6. 微信小程序实现首页图片多种排版布局!

    先来个效果图: 使用技术主要是flex布局,绝对定位布局,小程序前端页面开发,以及一些样式! 直接贴代码,都有详细注释,熟悉一下,方便以后小程序开发! wxml: <view class='in ...

  7. 如何在Axure中使用FontAwesome字体图标

    Font Awesome为您提供可缩放的矢量图标,您可以使用CSS所提供的所有特性对它们进行更改,包括:大小.颜色.阴影或者其它任何支持的效果. FontAwesome应用在web网页开发中非常方便, ...

  8. python多个分割符split字符串

    python中string自带的split不支持多个分隔符同时切分,用正则 import re line='hello,world' lineLists = re.split('[,,..??]',l ...

  9. git命令之git stash 暂存临时代码

    git stash — 暂存临时代码   stash命令可以很好的解决这样的问题.当你不想提交当前完成了一半的代码,但是却不得不修改一个紧急Bug,那么使用’Git stash’就可以将你当前未提交到 ...

  10. WebApi帮助类

    public class HttpClientBase { /// <summary> /// HttpClient实现Post请求 /// </summary> protec ...