计算几何-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): 3397Problem Descript

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
 
微笑大意:给出若干线段,计算交点个数。多条线段交于一点,需要重复计算。端点相交也算线段相交。
目录
打赏
0
0
0
0
14
分享
相关文章
|
10月前
杭电计算几何
杭电计算几何
49 0
C# | 凸包算法之Andrew‘s,获取围绕一组点的凸多边形的轮廓点
这篇关于凸包算法的文章,本文使用C#和Andrew’s算法来实现凸包算法。 首先消除两个最基本的问题: 什么是凸包呢? 凸包是一个包围一组点的凸多边形。凸多边形是指多边形中的每个内角都小于180度的多边形。 凸包算法有什么用呢? 凸包算法的作用是找到这个凸多边形,并且使用最少的点来绘制出它的轮廓。凸包算法在计算机图形学、计算几何和机器学习等领域中有着广泛的应用。
210 0
|
9月前
QuantLib学习笔记——看看几何布朗运动有没有股票走势的感觉
QuantLib学习笔记——看看几何布朗运动有没有股票走势的感觉
76 0
算法提高:计算几何基础 | 详解凸包问题
点集Q的凸包(convex hull)是指一个最小凸多边形,满足Q中的点或者在多边形边上,或者在其内
215 0
算法提高:计算几何基础 | 详解凸包问题
秒懂算法 | 计算几何:圆
计算几何的基础是点积和叉积,它们定义了向量的大小和方向的关系,是其他计算几何概念和算法的出发点。在点积和叉积的基础上,本篇重点介绍圆覆盖。 计算几何题目的代码大多繁琐冗长,因此掌握模板代码是学习计算几何的关键。本篇精心组织了经典的几何模板
18161 1
秒懂算法 | 计算几何:圆
【D3.js 学习总结】24、D3几何 - 多边形 
# d3.geom.polygon ![](https://img.alicdn.com/tps/TB1dXPjLXXXXXXBXVXXXXXXXXXX-500-506.png) polygon函数有3个用途: * polygon.area() 用来计算多边形面积; * polygon.centroid() 用来计算多边形中心坐标; * polygon.clip(subject)
2888 0
LDUOJ——山(计算几何+二分+精度)
LDUOJ——山(计算几何+二分+精度)
99 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等