poj 1269 题解
求直线交点,直接上代码。
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std;struct point{int x,y;point (){}point (int a,int b): x(a),y(b){}friend point operator + (const point &a,const point &b){return point(a.x+b.x,a.y+b.y);}friend point operator - (const point &a,const point &b){return point(a.x-b.x,a.y-b.y);}friend point operator * (const int &r,const point &a){return point(r*a.x,r*a.y);}};inline int det(point a,point b) {return a.x*b.y-a.y*b.x;} inline int dot(point a,point b) {return a.x*b.x+a.y*b.y;}inline bool On (point p,point s,point t){return det(p-s,t-s)==0; }inline bool parallel(point a,point b,point c,point d){return det(a-b,c-d)==0;}inline void line_make_point(point s1,point t1,point s2,point t2) //逻辑上必须先判断parallel {double a1=det(s1-s2,t2-s2);double a2=det(t1-s2,t2-s2);printf("POINT %.2f %.2f\n",1/(a1-a2)*(a1*t1.x-a2*s1.x),1/(a1-a2)*(a1*t1.y-a2*s1.y)); } int t; point s1,t1,s2,t2,ans; int x,y; int main() {scanf("%d",&t);printf("INTERSECTING LINES OUTPUT\n");while (t--){scanf("%d%d",&x,&y);s1=point(x,y);scanf("%d%d",&x,&y);t1=point(x,y);scanf("%d%d",&x,&y);s2=point(x,y);scanf("%d%d",&x,&y);t2=point(x,y);if (parallel(s1,t1,s2,t2)){if (On(s1,s2,t2))printf("LINE\n");else printf("NONE\n");continue;}else {line_make_point(s1,t1,s2,t2);}}printf("END OF OUTPUT\n");return 0; }
转载于:https://www.cnblogs.com/terra/p/7003169.html
poj 1269 题解相关推荐
- 暑期集训3:几何基础 练习题C: POJ - 1269
2018学校暑期集训第三天--几何基础 练习题B -- POJ - 1269 Intersecting Lines We all know that a pair of distinct point ...
- POJ 1269 Intersecting Lines(求直线交点)
http://poj.org/problem?id=1269 求交点见zhhx课件 #include<iostream> #include<cstdio> #include&l ...
- poj 1269 直线相交情况
链接:http://poj.org/problem?id=1269 题意:给两条直线,判断它们是重合.平行还是相交,相交则求交点. #include<iostream> #include& ...
- Coins POJ - 1742(题解)
原题 http://poj.org/problem?id=1742 题目大意 给出硬币面额及每种硬币的个数,求从1到m能凑出面额的个数. 题目分析 多重背包模板题,这里讲一下用一维dp来解这道题.与完 ...
- poj 1269 计算几何
题意:此题要处理给定的四个点,前两个点,后两个点分别构成一条直线,判断这两条直线是否重合,平行,相交,若相交,给出交点. 解题思路:可以用向量叉积判断是否重合和平行 重合:设第一个点和第二个点构成向量 ...
- 【POJ - 1269 】Intersecting Lines (计算几何,直线间的位置关系)
题干: We all know that a pair of distinct points on a plane defines a line and that a pair of lines on ...
- POJ 1154题解,此题不难理解方法就是DFS,属于水题。不过有一些细节要注意。...
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostre ...
- 【POJ 1269】判断两直线相交
题 利用叉积解方程 #include <cstdio> #define MAX 1<<31 #define dd double int xmult(dd x1,dd y1,dd ...
- POJ 2559 题解 最大矩形面积 单调栈
[题目描述]: 地面上从左到右并排紧挨着摆放多个矩形,已知这此矩形的底边宽度都为1,高度不完全相等.求在这些矩形包括的范围内能得到的面积最大的矩形,打印出该面积.所求矩形可以横跨多个矩形,但不能超出原 ...
- Aggressive cows POJ - 2456 题解
题目链接 点击这里 代码 #include <iostream> #include <algorithm>using namespace std;int N, M; const ...
最新文章
- emwin修改text字体颜色_Rggplot2 绘制带颜色条的相关性散点图
- RxSwift之UI控件Label扩展的使用
- C++代码片段(四)萃取模板类的模板参数类型
- 消灭星星网页版java代码,javascript实现消灭星星小游戏简单版
- 视不可当:信息图与可视化传播
- mysql体系结构和存储引擎
- 性能为MySQL 10倍!阿里云推出云原生数据仓库AnalyticDB基础版
- Kalman Filter : 理解卡尔曼滤波的三重境界
- SQL Server中的假期表和GetWorkDays函数
- EIGRP MD5认证实例
- html文件用的那个版本,html – 使用Django进行静态文件版本控制
- 对学习linux一周的总结
- spring boot Junit5单元测试
- 最实用的清理IE命令 ClearMyTracksByProcess
- 回文子串、回文子序列相关题目
- 使用ImageMagick如何对图片进行全面压缩
- html中小星星打分,折腾:2颗星星+纯CSS实现星星评分交互效果
- c语言李白喝酒答案,思维的体操——李白喝酒(2014年春蓝桥杯个人赛)
- Android:自动点击屏幕
- 【Android】Android SurfaceFlinger之BufferQueue
热门文章
- html div自动撑起来,解决子级用css float浮动 而父级div没高度不能自适应高度
- redis+tomcat实现session共享
- android通知栏内添加快捷键_Android实现向Launcher添加快捷方式的方法
- python xlwings api_python xlwings API接口之NumberFormat用法
- Redis的安装(windows)
- 【渝粤教育】国家开放大学2018年秋季 0053-21T移动通信技术与移动通信设备 参考试题
- 小数据、高准确率的文本分类:利用迁移学习创造通用语言模型
- 在64位linux上编译曾经在32位linux编译过,含有32位目标文件的错误的解决办法
- maven学习(五)——maven命令的组合使用
- 爬虫开发python工具包介绍 (4)