【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 ...
随机推荐
- UIButton关于setFont方法过时的解决方法
环境:xcode7 语言:Object-c 解决方法:更改UIButton的titleLabel属性的font值 一.新建一个Single View Application项目 二.创建一个UIBut ...
- datatable转json
//将datatable转化为json public string DataTableToJSON(DataTable dt) { JavaScriptSerializer jss = new Jav ...
- 九度OJ 1385 重建二叉树
题目地址:http://ac.jobdu.com/problem.php?pid=1385 题目描述: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都 ...
- SSH+Ajax实现用户名重复检查(一)
1.struts.xml设置 <package name="default" namespace="/" extends="json-defau ...
- MS SQL 维护小记
--查看当前连接的会话信息(进程号1--50是SQL Server系统内部用的) SELECT * FROM sys.dm_exec_sessions WHERE session_id >=51 ...
- C# DllImport的用法
大家在实际工作学习C#的时候,可能会问:为什么我们要为一些已经存在的功能(比如Windows中的一些功能,C++中已经编写好的一些方法)要重新编写代码,C#有没有方法可以直接都用这些原本已经存在的功能 ...
- 解决使用 Composer 的时候提示输入 Token
Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=0 ...
- PythonCrawl自学日志(4)
2016年9月22日10:34:02一.Selector1.如何构建(1)text构建: body = '<html><body><span>good</sp ...
- Python Mixin混入的使用方法
DEMO # encoding=utf-8 __author__ = 'kevinlu1010@qq.com' class Base(): def f1(self): print 'I am f1 i ...
- 在树莓派上部署asp.net
今天成功的在树莓派上部署asp.net呢.之前在unbuntu上测试成功了,结果今天操作的时候又不会操作了,主要对Linux太不熟悉了,找资料,资料又不多,这次赶紧记录下来,以备下次查阅. 我用的mo ...