【HDOJ】1086 You can Solve a Geometry Problem too
数学题,证明AB和CD。只需证明C、D在AB直线两侧,并且A、B在CD直线两侧。
公式为:(ABxAC)*(ABxAD)<= 0 and(CDxCA)*(CDxCB)<= 0
#include <stdio.h>
#define MAXNUM 105
typedef struct {
double x1, y1;
double x2, y2;
} line_st;
line_st lines[MAXNUM];
int cal(int i, int j) {
double ab_x, ab_y, ac_x, ac_y, ad_x, ad_y;
double a, b;
ab_x = lines[i].x2 - lines[i].x1;
ab_y = lines[i].y2 - lines[i].y1;
ac_x = lines[j].x1 - lines[i].x1;
ac_y = lines[j].y1 - lines[i].y1;
ad_x = lines[j].x2 - lines[i].x1;
ad_y = lines[j].y2 - lines[i].y1;
a = ab_x*ac_y - ab_y*ac_x;
b = ab_x*ad_y - ab_y*ad_x;
if (a*b <= )
return ;
else
return ;
}
int main() {
int n;
int i, j, k;
while (scanf("%d", &n)!=EOF && n) {
for (i=; i<n; ++i)
scanf("%lf%lf%lf%lf", &lines[i].x1,&lines[i].y1,&lines[i].x2,&lines[i].y2);
k = ;
for (i=; i<n; ++i)
for (j=; j<i; ++j)
if (cal(i, j) && cal(j, i))
k++;
printf("%d\n", k);
}
return ;
}
【HDOJ】1086 You can Solve a Geometry Problem too的更多相关文章
- hdu 1086 You can Solve a Geometry Problem too
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- hdu 1086:You can Solve a Geometry Problem too(计算几何,判断两线段相交,水题)
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- hdu 1086 You can Solve a Geometry Problem too (几何)
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- hdu 1086 You can Solve a Geometry Problem too 求n条直线交点的个数
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- Hdoj 1086.You can Solve a Geometry Problem too 题解
Problem Description Many geometry(几何)problems were designed in the ACM/ICPC. And now, I also prepare ...
- hdu 1086 You can Solve a Geometry Problem too [线段相交]
题目:给出一些线段,判断有几个交点. 问题:如何判断两条线段是否相交? 向量叉乘(行列式计算):向量a(x1,y1),向量b(x2,y2): 首先我们要明白一个定理:向量a×向量b(×为向量叉乘),若 ...
- HDU 1086 You can Solve a Geometry Problem too( 判断线段是否相交 水题 )
链接:传送门 题意:给出 n 个线段找到交点个数 思路:数据量小,直接暴力判断所有线段是否相交 /*************************************************** ...
- HDU 1086:You can Solve a Geometry Problem too
pid=1086">You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Mem ...
- You can Solve a Geometry Problem too(线段求交)
http://acm.hdu.edu.cn/showproblem.php?pid=1086 You can Solve a Geometry Problem too Time Limit: 2000 ...
随机推荐
- dubbo监控活跃线程数
telnet对应dubbo服务的ip+端口号 status -l 其中的active就是当前的活跃线程数 通过程序定时探测写入DB,再查询渲染出来就好了 监控报警,如果已经有监控平台,可以通过一定的规 ...
- (poj)3020 Antenna Placement 匹配
题目链接 : http://poj.org/problem?id=3020 Description The Global Aerial Research Centre has been allotte ...
- div高度自适应填充剩余部分
在乐学一百的开发过程中,遇到了一个小乐Fm开发,需要跟百度fm差不多,上边一个条,下边一个条,中间部分填充.但是还不能固定高度,因为屏幕的宽高都不一样...height:100%是不可行的.搜了一圈, ...
- QtSQL学习笔记(4)- 使用SQL Model类
除了QSqlQuery,Qt提供了3个高级类用于访问数据库.这些类是QSqlQueryModel.QSqlTableModel和QSqlRelationalTableModel. 这些类是由QAbst ...
- DataTable 数据量大时,导致内存溢出的解决方案
/// <summary> /// 分解数据表 /// </summary> /// <param name="originalTab">需要分 ...
- 要做一款APP-解放双手
对方打字或发语音,我可以选择看屏幕或者听. 我说话,能够转化为文字.不需要点击开始按钮的那种.
- 使用WebClient上传文件并同时Post表单数据字段到服务端
之前遇到一个问题,就是使用WebClient上传文件的同时,还要Post表单数据字段,一开始以为WebClient可以直接做到,结果发现如果先 Post表单字段,就只能获取到字段及其值,如果先上传文件 ...
- cgi创建web应用(一)之传递表单数据与返回html
主旨: 0.环境说明 1.创建一个cgi本地服务 2.创建一个html表单页 3.创建一个对应的cgi 脚本文件 4.运行调试 0.环境说明: 系统:win7 32位家庭版 python:2.7 代码 ...
- iis7以上版本权限控制
IIS7.5中(仅win7,win2008 SP2,win2008 R2支持),应用程序池的运行帐号,除了指定为LocalService,LocalSystem,NetWorkService这三种基本 ...
- Popen No such file or directory 错误
File , in reload_config stderr=PIPE, env={"PATH": '', "HOME": "/root"} ...