数学题,证明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的更多相关文章

  1. 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 ...

  2. 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 ...

  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 ...

  4. 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 ...

  5. 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 ...

  6. hdu 1086 You can Solve a Geometry Problem too [线段相交]

    题目:给出一些线段,判断有几个交点. 问题:如何判断两条线段是否相交? 向量叉乘(行列式计算):向量a(x1,y1),向量b(x2,y2): 首先我们要明白一个定理:向量a×向量b(×为向量叉乘),若 ...

  7. HDU 1086 You can Solve a Geometry Problem too( 判断线段是否相交 水题 )

    链接:传送门 题意:给出 n 个线段找到交点个数 思路:数据量小,直接暴力判断所有线段是否相交 /*************************************************** ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. c# 中模拟一个模式匹配及匹配值抽取

    摘一段模式的说明, F#的: msdn是这么描述它的:“模式”是用于转换输入数据的规则.模式将在整个 F# 语言中使用,采用多种方式将数据与一个或多个逻辑结构进行比较.将数据分解为各个构成部分,或从数 ...

  2. 关于Encoding.GetEncoding("utf-8")和Encoding.GetEncoding("GB2312")及Encoding.Default

    关于Encoding.GetEncoding("utf-8")和Encoding.GetEncoding("GB2312")及Encoding.Default ...

  3. (转)Quartz.NET管理类

    最近做项目设计到Quartz.NET,写了一个Quartz.NET管理类,在此记录下. public class QuartzManager<T> where T : class,IJob ...

  4. 九度OJ 1120 全排列 -- 实现C++STL中next_permutation()

    题目地址:http://ac.jobdu.com/problem.php?pid=1120 题目描述: 给定一个由不同的小写字母组成的字符串,输出这个字符串的所有全排列. 我们假设对于小写字母有'a' ...

  5. POJ 1170 Shopping Offers -- 动态规划(虐心的六重循环啊!!!)

    题目地址:http://poj.org/problem?id=1170 Description In a shop each kind of product has a price. For exam ...

  6. WinForm应用程序退出的方法

    this.Close(); 只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出. Application.Exit(); 强制所有消息中止,退出所有的 ...

  7. 关于$.fn

    今天看一篇文章,里面的一段代码出现了$.fn,第一次见到这样的写法,于是跑去问度娘...代码如下: $.fn.scrollUnique = function() { return $(this).ea ...

  8. 解决 IE 不支持 document.getElementsByClassName() 的方法

    //create method getElementsByClassName for document if(!document.getElementsByClassName){ document.g ...

  9. MS SQL 维护小记

    --查看当前连接的会话信息(进程号1--50是SQL Server系统内部用的) SELECT * FROM sys.dm_exec_sessions WHERE session_id >=51 ...

  10. Cassandra1.2文档学习(8)—— 数据管理

    数据参考:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/dml/dml_manage ...