poj 1066 Treasure Hunt (未完)
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define eps 1e-8
#define zero(x) (((x)>0 ? (x):(-x))<eps)
#define INF 0x3f3f3f3f
struct Point
{
double x,y;
}tre,point[],tp;
struct Line
{
Point a,b;
}line[];
double xmult(Point p1,Point p2,Point p0)
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
double dmult(Point p1,Point p2,Point p0)
{
return (p1.x-p0.x)*(p2.x-p0.x)+(p1.y-p0.y)*(p2.y-p0.y);
}
int dis(Point p1,Point p2)
{
return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
}
int cmp(const void *a,const void *b)
{
Point *c=(Point *)a;
Point *d=(Point *)b;
int k=xmult(point[],*c,*d);
if(k<||!k&&dis(point[],*c)>dis(point[],*d))
return ;
return -;
}
int main()
{
int i,j,n,ans,tmp;
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%lf%lf%lf%lf",&line[i].a.x,&line[i].a.y,&line[i].b.x,&line[i].b.y);
point[*i]=line[i].a;
point[*i+]=line[i].b;
}
scanf("%lf%lf",&tre.x,&tre.y); int m=n;
point[m].x=point[m++].y=;
point[m].x=;point[m++].y=;
point[m].x=point[m++].y=;
point[m].x=;point[m++].y=; qsort(point+,m-,sizeof(Point),cmp);
point[m++]=point[]; ans=INF;
for(i=;i<m-;i++)
{
tmp=;
//tp.x=(point[i].x+point[i+1].x)/2;
//tp.y=(point[i].y+point[i+1].y)/2;
tp=point[i];
for(j=;j<n;j++)
{
if(xmult(tre,line[j].a,line[j].b)*xmult(tp,line[j].a,line[j].b)<-eps&&
xmult(line[j].a,tre,tp)*xmult(line[j].b,tre,tp)<-eps)tmp++;
}
if(tmp<ans)ans=tmp;
}
printf("Number of doors = %d\n",ans-);
return ;
}
poj 1066 Treasure Hunt (未完)的更多相关文章
- poj 1066 Treasure Hunt (Geometry + BFS)
1066 -- Treasure Hunt 题意是,在一个金字塔中有一个宝藏,金字塔里面有很多的墙,要穿过墙壁才能进入到宝藏所在的地方.可是因为某些原因,只能在两个墙壁的交点连线的中点穿过墙壁.问最少 ...
- POJ 1066 Treasure Hunt(线段相交判断)
Treasure Hunt Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4797 Accepted: 1998 Des ...
- POJ 1066 Treasure Hunt(相交线段&&更改)
Treasure Hunt 大意:在一个矩形区域内.有n条线段,线段的端点是在矩形边上的,有一个特殊点,问从这个点到矩形边的最少经过的线段条数最少的书目,穿越仅仅能在中点穿越. 思路:须要巧妙的转换一 ...
- POJ 1066 - Treasure Hunt - [枚举+判断线段相交]
题目链接:http://poj.org/problem?id=1066 Time Limit: 1000MS Memory Limit: 10000K Description Archeologist ...
- poj 1066 Treasure Hunt
http://poj.org/problem?id=1066 #include <cstdio> #include <cstring> #include <cmath&g ...
- POJ 1066 Treasure Hunt [想法题]
题目链接: http://poj.org/problem?id=1066 --------------------------------------------------------------- ...
- POJ 1066 Treasure Hunt (线段相交)
题意:给你一个100*100的正方形,再给你n条线(墙),保证线段一定在正方形内且端点在正方形边界(外墙),最后给你一个正方形内的点(保证不再墙上) 告诉你墙之间(包括外墙)围成了一些小房间,在小房间 ...
- POJ 1066 Treasure Hunt【线段相交】
思路:枚举四边墙的门的中点,与终点连成一条线段,判断与其相交的线段的个数.最小的加一即为答案. 我是傻逼,一个数组越界调了两个小时. #include<stdio.h> #include& ...
- POJ 1066 Treasure Hunt --几何,线段相交
题意: 正方形的房子,给一些墙,墙在区域内是封闭的,给你人的坐标,每穿过一道墙需要一把钥匙,问走出正方形需要多少把钥匙. 解法: 因为墙是封闭的,所以绕路也不会减少通过的墙的个数,还不如不绕路走直线, ...
随机推荐
- 安卓5.0宣告了ARM平台全面进入64位时代
安卓5.0宣告了ARM平台全面进入64位时代 2014年10月份,安卓5.0正式版发布了,安卓5.0支持64位CPU,安卓5.0全面启用ART运行模式,在程序安装的时候,进行预编译,新的运行环境能够使 ...
- NGINX conf 配置文件中的变量大全 可用变量列表及说明
$args #这个变量等于请求行中的参数.$content_length #请求头中的Content-length字段.$content_type #请求头中的Content-Type字段.$docu ...
- 性能监控之Spotlight
有和同事探讨一些技术监控类软件,谈到Spotlight,临时记一下. 下载地址https://pan.baidu.com/s/1HB9xd9LmOR-MOk8FIGBm-A 常规安装模式,下载解压安装 ...
- linux c下,从路径名中分离文件名
首先介绍一些查找字符的函数 1.strrchr 头文件:#include <string.h> strrchr() 函数用于查找某字符在字符串中最后一次出现的位置,其原型为: ch ...
- 【UVA】673 Parentheses Balance(栈处理表达式)
题目 题目 分析 写了个平淡无奇的栈处理表达式,在WA了5发后发现,我没处理空串,,,,(或者说鲁棒性差? 代码 #include <bits/stdc++.h> usin ...
- android.support.v4.app.Fragment vs android.app.Fragment 的区别
android.support.v4.app.Fragment vs android.app.Fragment 的区别 我开过平板相关应用,用了Fragment来处理.后来重新开发另外一个应用,直接引 ...
- hibernate操作数据库时报错解决方式
java.sql.SQLException: Parameter index out of range (28 > number of parameters, which is 27). 这个说 ...
- PHP mysql client封装
config1.inc.php $CONFIG_DATABASE_TXL = array( #array('127.0.0.1', 'root', '', 'he_txl','3306') array ...
- Linux 下 实现 锐捷验证的方式
准备工作:下载mentohust并安装 步骤: 1.打开终端,输入sudo mentohust 2.配置相关参数,网卡选第一个,用户名密码自己输入,类型选锐捷私有,DHCP选认证前.完成后回车即可通过 ...
- 好记性不如烂笔头-Mysql查找如何判断字段是否包含某个字符串
好记性不如烂笔头-Mysql查找如何判断字段是否包含某个字符串 利用mysql 字符串函数 find_in_set(); SELECT * FROM users WHERE find_in_set(' ...