【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 ...
随机推荐
- Web前端开发:SQL Jsp小项目(二)------添加修改
沿着昨天整理好的页面,今天实现list页面中的修改, User update框架 需要的效果图: 先看用户查询界面, 修改id为4的那个用户: 修改后返回用户查看界面. 1 .先是从list界面开始, ...
- MySQL的记录长度
MySQL的记录长度 MySQL默认规定一条记录最大的长度是65535字节,所有的字段加在一起所占的字节数不能超过65535.但是MySQL中字段的长度有的时使用字节来规定int,有些字段类型是使用字 ...
- java_object的具体使用--上帝
就我们所知道的,java中有子类和父类,子类由于继承父类而形成,那么父类还有没有父类呢?答案是有了,父类的父类就是object类,一切父类都继承了它,那么根据继承的属性,每一个子类都有一个object ...
- makefile--Unfound symbol
Unfound symbol ,库函数的包含问题或者头文件包含问题 makefile对#的识别度太低了,如果使用了,#它之后的可能就不能识别了,然后会报错的Unfound symbol /////// ...
- N的N次方(高校俱乐部)
最近一直在刷字符串和线段树,也越来越少玩高校俱乐部,无聊看到一题N的N次方的问题,脑海中各种打表就涌现出来了. 弄了不一会儿,就写完了,马上提交,但是系统好像出了问题,提示"哦哦,出了点状况 ...
- install xdebug on fedora
Compiling There is a wizard available that provides you with the correct file to download, and which ...
- 【转】SQL2008清除日志
USE [master] GO ALTER DATABASE DNName SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE DNName SET ...
- js 框架都有哪几种(转载)
目前来看,js框架以及一些开发包和库类有如下几个,Dojo .Scriptaculous .Prototype .yui-ext .Jquery .Mochikit.mootools .moo.fxD ...
- 开发设计模式(六)多例模式(Multition Pattern)
多例模式实际上就是单例模式的扩充,多例模式又划分为有上限多例模式和无上限多例模式两种,有上限多例模式中的多例类的实例是有上限的,当这个多例类中的上限数值上等于 1 时,此时,多例类退化回到了单例类:而 ...
- POJ 3254 压缩状态DP
题意:一个矩形网格,可以填0或1, 但有些位置什么数都不能填,要求相邻两个不同时为1,有多少种填法.矩形大小最大 12*12. 压缩状态DP大多有一个可行的state的范围,先求出这个state范围, ...