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 ...
随机推荐
- IntelliJ IDEA 破解 - pycharm
MAC激活方法 下载破解文件 下载地址: https://files.cnblogs.com/files/resn/JetbrainsCrack-2.7-release-str.jar.zip 或者去 ...
- Stochastic Optimization Techniques
Stochastic Optimization Techniques Neural networks are often trained stochastically, i.e. using a me ...
- git 学习小记之记住https方式推送密码
昨天刚刚学了点git基础操作,但是不幸的是Git@OSC给出公告说尽量使用 https 进行操作.可是在用 https 进行 push 时,都需要输入帐号和密码. 各种百度谷歌之后在Git@OSC官网 ...
- Firefox滚动残影(转)
Firefox滚动残影 Firefox滚动残影这文章放在草稿箱有一阵子了,之前的3系列都有这BUG,当正想发表这文章的时候,和我沟通刚刚升级的FF4已修复此BUG,所以搁置一阵在考虑到这文章还有没 ...
- 第13月第12天 Constraints priority
1.Constraints priority 将evInputView的高度约束的priority设为750,evInputView的inputTextView如果不设高度约束,那么高度就是defau ...
- F - A计划
题目链接: https://cn.vjudge.net/contest/254150#problem/F wa代码: #include<iostream> #include<stri ...
- Servlet、ServletConfig、ServletContext深入学习
1.Servlet学习 1.Servlet生命周期 Servlet 加载—>实例化—>服务—>销毁. init(servletConfig):(经过自己的测试发现会先调用这个而不是i ...
- Virut.ce-感染型病毒分析报告
1.样本概况 病毒名称 Virus.Win32.Virut.ce MD5 6A500B42FC27CC5546079138370C492F 文件大小 131 KB (134,144 字节) 壳信息 无 ...
- linux内核环形缓冲区【转】
转自:https://blog.csdn.net/eydwyz/article/details/56671023 循环缓冲区在一些竞争问题上提供了一种免锁的机制,免锁的前提是,生产者和消费 都只有一个 ...
- Linux下利用backtrace追踪函数调用堆栈以及定位段错误【转】
转自:https://www.linuxidc.com/Linux/2012-11/73470p2.htm 通常情况系,程序发生段错误时系统会发送SIGSEGV信号给程序,缺省处理是退出函数.我们可以 ...