【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 ...
随机推荐
- [python] 高效使用assert
Places to consider putting assertions: checking parameter types, classes, or values checking data st ...
- C# Generic(转载)
型(generic)是C#语言2.0和通用语言运行时(CLR)的一个新特性.泛型为.NET框架引入了类型参数(type parameters)的概念.类型参数使得设计类和方法时,不必确定一个或多个具体 ...
- sea.js总结
SeaJS是一个遵循CommonJS规范的JavaScript模块加载框架. 参考以下网址进行详细学习: https://segmentfault.com/a/1190000000357191?pag ...
- Web前端新人笔记之HeightCharts基础
通常情况下,Highcharts包含标题(Title).坐标轴(Axis).数据列(Series).数据提示框(Tooltip).图例(Legend).版权信息(Credits)等,高级的还包括导出功 ...
- Windows server2008/2012 安装oracle 11 创建实例HANG住在百分之2
Windows server2008/2012 安装oracle 11.2.0.1的时候,可能会在创建数据库实例的时候卡在百分之2的地方. 这个时候可以 1.点击开始菜单,在“搜索程序和文件”中输入“ ...
- java中的多线程——进度2
package src;/*多线程总结:1,进程和线程的概念. |--进程: |--线程:2,jvm中的多线程体现. |--主线程,垃圾回收线程,自定义线程.以及他们运行的代码的位置 ...
- php生成随机产生六位数密码的代码
php生成随机产生六位数密码的代码,供大家学习参考.本文转自:http://www.jbxue.com/article/6199.html php生成随机产生六位数密码的代码,供大家学习参考. 复制代 ...
- 用 BPL 封装数据连接
BPL 代码: uDM.pas unit uDM; interface uses SysUtils, Classes, uIntf, DB, ABSMain; type TDM = class(TDa ...
- 【python】Python 3 +pycharm中文支持解决方案
使用环境:window10 + python 3.5.1 方法:在代码前端增加代码:# -*-coding:gbk-*-
- Java EJX
EJX http://www.docin.com/p-121548732.html