URAL 1963 Kite 计算几何
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 计算几何的更多相关文章
- URAL 1963 Kite 四边形求对称轴数
题目链接: http://acm.timus.ru/problem.aspx?space=1&num=1963 题意,顺时针或逆时针给定4个坐标,问对称轴有几条,输出(对称轴数*2) 对于一条 ...
- C - Kite URAL - 1963 (几何+四边形判断对称轴)
题目链接:https://cn.vjudge.net/problem/URAL-1963 题目大意:给你一个四边形的n个点,让你判断对称点的个数(对称轴的个数*2). 具体思路:感谢qyn的讲解,具体 ...
- 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 ...
- URAL 1775 B - Space Bowling 计算几何
B - Space BowlingTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- Ural 1046 Geometrical Dreams(解方程+计算几何)
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1046 参考博客:http://hi.baidu.com/cloudygoose/item ...
- URAL 2099 Space Invader题解 (计算几何)
啥也不说了,直接看图吧…… 代码如下: #include<stdio.h> #include<iostream> #include<math.h> using na ...
- URAL 1966 Cycling Roads 计算几何
Cycling Roads 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/F Description When Vova was ...
- 【计算几何】URAL - 2101 - Knight's Shield
Little Peter Ivanov likes to play knights. Or musketeers. Or samurai. It depends on his mood. For pa ...
- URAL 1750 Pakhom and the Gully 计算几何+floyd
题目链接:点击打开链接 gg.. . #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cs ...
随机推荐
- linux解压
tar –xvf file.tar //解压 tar包tar -xzvf file.tar.gz //解压tar.gztar -xjvf file.tar.bz2 //解压 tar.bz2tar –x ...
- Why do we make statistics so hard for our students?
Why do we make statistics so hard for our students? (Warning: long and slightly wonkish) If you’re l ...
- python学习笔记6--双色球需求实现
# 5,随机产生5条双色球号码 # blue 存蓝色的求 01,02 # red 存红色的求 17,16,03 # date存生成的时间,精确达到秒 #处理 import random,datetim ...
- Struts2_day02
一.内容大纲 1 结果页面配置 (1)全局结果页面 (2)局部结果页面 - 配置全局也配置局部,最终局部为准 (3)result标签type属性 - 默认值 dispatcher做转发 - redir ...
- [转载]在Windows下搭建Android开发环境
http://jingyan.baidu.com/article/bea41d437a41b6b4c51be6c1.html 在Windows下搭建Android开发环境 | 浏览:30780 | 更 ...
- CSS-3 Transition 的使用
css的transition允许css的属性值在一定的时间区间内平滑地过渡.这种效果可以在鼠标单击.获得焦点.被点击或对元素任何改变中触发,并圆滑地以动画效果改变CSS的属性值." tran ...
- 洛谷 P1525 【关押罪犯】种类并查集
题解 P1525 [关押罪犯]:种类并查集 前言: 在数据结构并查集中,种类并查集属于扩展域并查集一类. 比较典型的题目就是:食物链(比本题难一些,有三个种类存在) 首先讲一下本题的贪心,这个是必须要 ...
- 用U盘安装 win7 ”找不到任何设备驱动程序“ 和 系统出现 windows boot manager 解决方案
用U盘安装win7系统时,系统交替的出现了如下的2个错误,捣鼓了半天,记录下来: 问题1描述: 安装win7时 ”找不到任何设备驱动程序“ 问题2描述: 安装win7时,用U盘启动后, 系统出现 ...
- 【webService客户端】webservice客户端工具
public static Object invokeWebService(String namespaces,String url, String method, Object[] params, ...
- C型USB能阻止危险充电器通过USB传播恶意软件
C型USB能阻止危险充电器通过USB传播恶意软件 C型USB设备(USB Type-C)的新型身份验证协议可以保护用户免受潜在的充电器损坏的风险,这种新型的USB还能减少被恶意软件的风险.基于密码的认 ...