这个题目要注意的是:给出的矩形坐标不一定是按照左上,右下这个顺序的 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define eps 1e-8 #define INF 1e9 using namespace std; const int maxn=100; typedef struct Point {…
题目链接 题意 判断线段和矩形是否有交点(矩形的范围是四条边及内部). 思路 判断线段和矩形的四条边有无交点 && 线段是否在矩形内. 注意第二个条件. Code #include <cstdio> #include <cmath> #include <iostream> #include <cstring> #define inf 0x3f3f3f3f #define eps 1e-6 #define maxn 110 using name…
题意: 无反射不透明管子, 问从入口射入的所有光线最远能到达的横坐标. 贯穿也可. 思路: 枚举每一组经过 up [ i ] 和 down [ j ] 的直线, 计算最远点. 因为无法按照光线生成的方式确定点斜式的起始点及斜率(连续的), 于是换另一种思路: 反正最终是要判断可行的直线, 就直接选择一些有代表性的直线, 覆盖所有边界即可. 于是考虑边界是什么. 首先可以发现: 由于光线是入口整个发出的, 其实也就是入口和拐点是平等的. 只要判相交. 只要覆盖在整个管道范围内的直线就可以, 由于不…
题目大意: 询问给定n条线段 是否存在一条直线使得所有线段在直线上的投影存在公共点 这个问题可以转化为 是否存在一条直线与所有的线段同时相交 而枚举直线的问题 因为若存在符合要求的直线 那么必存在穿过某线段的端点的直线是符合要求的直线 那么只要枚举两个端点连成一线 #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> using namespace std; ;…
Intersection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16322   Accepted: 4213 Description You are to write a program that has to decide whether a given line segment intersects a given rectangle. An example: line: start point: (4,9)…
题目大意: 给定n条线段 接下来n行是端点信息 接下来询问 a b 是否相交 若a与c相交 b与c相交 ,那么a与b就是相交的 先判断任两条线段是否相交 再用folyd #include <cstdio> #include <cmath> #include <algorithm> #include <stdio.h> #include <string.h> using namespace std; ; double add(double a,do…
题目链接:https://vjudge.net/contest/276358#problem/C 题目大意:给你n条线段,问你是否存在一条线段使得所有的线段在这条直线的投影至少具有一个交点? 具体思路:这个题转换一下思路,假设存在一条直线与所有的线段都相交,那么这条直线的垂线就是题目中所求的直线,我们可以把所有的端点都遍历一遍,询问一下看有没有符合条件的直线就可以了. AC代码: /*********************************************************…
题目大意: 给出多个多边形及其编号 按编号顺序输出每个多边形与其相交的其他多边形编号 注意一个两个多个的不同输出 将每个多边形处理成多条边 然后去判断与其他多边形的边是否相交 计算正方形另外两点的方法https://blog.csdn.net/qq_33328072/article/details/51655746 根据对角线 x0 + x2 =  x1 + x3 y0 + y2 =  y1 + y3 根据全等三角形 x1 - x3 = y2 - y1 y1 - y3 = x2 - x0 得到…
题目链接:http://poj.org/problem?id=1410 Intersection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12822   Accepted: 3347 Description You are to write a program that has to decide whether a given line segment intersects a given rectangle.…
题目链接:https://vjudge.net/problem/POJ-1410 题意:判断线段和矩形是否相交. 思路:注意这里的相交包括线段在矩形内,因此先判断线段与矩形的边是否相交,再判断线段的两端点是否在矩形内(因为是矩形,即凸多边形,直接用叉积判断即可,如果是一般的多边形,需要用射线法判断.) AC code: #include<cstdio> #include<algorithm> #include<cmath> #include<cstdlib>…