计算几何-hdoj-1086

You can Solve a Geometry Problem too

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7027    Accepted Submission(s): 3397

Problem Description

Many geometry(几何)problems were designed in the ACM/ICPC. And now, I also prepare a geometry problem for this final exam. According to the experience of many ACMers, geometry problems are always much trouble, but this problem is very
easy, after all we are now attending an exam, not a contest :)
Give you N (1<=N<=100) segments(线段), please output the number of all intersections(交点). You should count repeatedly if M (M>2) segments intersect at the same point.
Note:
You can assume that two segments would not intersect at more than one point.

Input

Input contains multiple test cases. Each test case contains a integer N (1=N<=100) in a line first, and then N lines follow. Each line describes one segment with four float values x1, y1, x2, y2 which are coordinates of the segment’s
ending.
A test case starting with 0 terminates the input and this test case is not to be processed.

Output

For each case, print the number of intersections, and one line one case.

Sample Input


2
0.00 0.00 1.00 1.00
0.00 1.00 1.00 0.00
3
0.00 0.00 1.00 1.00
0.00 1.00 1.00 0.000
0.00 0.00 1.00 0.00
0

 

Sample Output

1

3

 

大意:给出若干线段,计算交点个数。多条线段交于一点,需要重复计算。端点相交也算线段相交。

时间: 2024-12-23 21:24:31

计算几何-hdoj-1086的相关文章

POJ 1265 Area (计算几何)(Pick定理)

Area:http://poj.org/problem?id=1265 计算几何)(Pick定理)-poj1265"> 大意:每次给你一个点的横纵坐标变化值,求有多少点在多边形上,有多少点在多边形内,和多边形的面积. 思路:Pick定理. 一个计算点阵中顶点在格点上的多边形面积公式:S=a+b÷2-1,其中a表示多边形内部的点数,b表示多边形边界上的点数,s表示多边形的面积. 更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Progr

POJ 3218 TOYS(计算几何)(二分)

TOYS:http://poj.org/problem?id=2318 大意:给你一个箱子,有n个挡板分隔成n+1部分,给你m个玩具的坐标,问每一部分有几个玩具. 思路:举对每个玩具,二分线段下标,判断玩具在线段左边还是右边,枚举后统计. 更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/ #include <map> #include <stack> #include <queue>

UVa 438 The Circumference of the Circle (计算几何)

438 - The Circumference of the Circle Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=379 To calculate the circumference of a circle seems to be an easy t

UVa 10387 Billiard:计算几何&amp;amp;反射

10387 - Billiard Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=101&page=show_problem&problem=1328 In a billiard table with horizontal side a inches and vertical side b inches, a bal

UVa 143 Orchard Trees:数学&amp;amp;计算几何&amp;amp;枚举

143 - Orchard Trees Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=79 An Orchardist has planted an orchard in a rectangle with trees uniformly spaced in both directions.

UVa 10112 Myacm Triangles:枚举&amp;amp;计算几何

10112 - Myacm Triangles Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=101&page=show_problem&problem=1053 计算几何-puzzle acm uva227">There has been considerable archeological wo

POJ 2606 / URAL 1502 Rabbit hunt:计算几何

1052. Rabbit Hunt http://poj.org/problem?id=2606 http://acm.timus.ru/problem.aspx?space=1&num=1052 Time limit: 1.0 second Memory limit: 64 MB A good hunter kills two rabbits with one shot. Of course, it can be easily done since for any two points we

算法系列(九) 计算几何与图形学有关的几种常用算法(二)

3.6 用矢量的叉积判断直线段是否有交 矢量叉积计算的另一个常用用途是直线段求交.求交算 法是计算机图形学的核心算法,也是体现速度和稳定性的重要标志,高效并且稳定的求交算法是任何 一个CAD软件都必需要重点关注的.求交包含两层概念,一个是判断是否相交,另一个是求出交点.直 线(段)的求交算法相对来说是比较简单的,首先来看看如何判断两直线段是否相交. 常规的 代数计算通常分三步,首先根据线段还原出两条线段所在直线的方程,然后联立方程组求出交点,最 后再判断交点是否在线段区间上.常规的代数方法非常繁

1086: 弟弟的作业

Description 你的弟弟刚做完了"100以内数的加减法"这部分的作业,请你帮他检查一下.每道题目(包括弟弟的答案)的格式为a+b=c或者a-b=c,其中a和b是作业中给出的,均为不超过100的非负整数:c是弟弟算出的答案,可能是不超过200的非负整数,也可能是单个字符"?",表示他不会算. Input 输入文件包含不超过100行,以文件结束符结尾.每行包含一道题目,格式保证符合上述规定,且不包含任何空白字符.输入的所有整数均不含前导0. Output 输出仅

怎么用计算几何解决这个问题?

问题描述 怎么用计算几何解决这个问题? 先给你一个简单的例子,已知8个点坐标,实际上是一个立方体的8个顶点坐标,通过程序实现这是一个立方体,由6个面构成,每个面又由4条线构成,每条线又由2个点构成.每个元素(点,线,面)都要能够通过程序检索信息,比如说线的长度,面的面积.这个用计算几何怎么解决 解决方案 http://zhidao.baidu.com/link?url=JjJ-o5Hs8tMAX9s26k3xWC_ylx-QQpmZH3WfxH6If0NE_9xykbQcwBtkvZ2e9oFH