poj 1269 Intersecting Lines(判断两条直线三种状态)

三、CornerstoneTools中的工具介绍使用 CornelstoneTools 事件将本地事件捕获,并进行规范化,并使用 cornerstonetools 前缀重新触发,这样在不同的浏览器中可以一致地处理事件。Cornerstone Tools 所有的工具均为 class 类,都是通过继承 class 类的方式实现统一的集成。📢 注意:在同一种绑定方式下有且仅有一种工具被激活,不会有两个工具被激活。注册的工具处于以下四种模式之一,每种模式都会影响工具对交互的响应方式。查看当前的cornerstoneTools版本号。 阅读详情

Intersecting Lines
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 16792 Accepted: 7233

Description

We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect in a line because they are on top of one another (i.e. they are the same line), 3) intersect in a point. In this problem you will use your algebraic knowledge to create a program that determines how and where two lines intersect. 
Your program will repeatedly read in four points that define two lines in the x-y plane and determine how and where the lines intersect. All numbers required by this problem will be reasonable, say between -1000 and 1000. 

Input

The first line contains an integer N between 1 and 10 describing how many pairs of lines are represented. The next N lines will each contain eight integers. These integers represent the coordinates of four points on the plane in the order x1y1x2y2x3y3x4y4. Thus each of these input lines represents two lines on the plane: the line through (x1,y1) and (x2,y2) and the line through (x3,y3) and (x4,y4). The point (x1,y1) is always distinct from (x2,y2). Likewise with (x3,y3) and (x4,y4).

Output

There should be N+2 lines of output. The first line of output should read INTERSECTING LINES OUTPUT. There will then be one line of output for each pair of planar lines represented by a line of input, describing how the lines intersect: none, line, or point. If the intersection is a point then your program should output the x and y coordinates of the point, correct to two decimal places. The final line of output should read "END OF OUTPUT".

Sample Input

5
0 0 4 4 0 4 4 0
5 0 7 6 1 0 2 3
5 0 7 6 3 -6 4 -3
2 0 2 27 1 5 18 5
0 3 4 0 1 2 2 5

Sample Output

INTERSECTING LINES OUTPUT
POINT 2.00 2.00
NONE
LINE
POINT 2.00 5.00
POINT 1.07 2.20
END OF OUTPUT

分析:这个提示真的坑,代码注释自己看吧。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	scanf("%d",&n);
	printf("INTERSECTING LINES OUTPUT\n");
	while(n--)
	{
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		
		if((x4-x3)*(y2-y1)==(y4-y3)*(x2-x1)) //斜率判断 
		{
			if((x2-x1)*(y3-y1)==(y2-y1)*(x3-x1))// 叉乘判断是否重合 (取一条线上俩点加另外一条直线上一个点) 
				printf("LINE\n");
			else
				printf("NONE\n");
		}
		else
		{
			double A1=y2-y1;	double B1=x1-x2;	double C1=x2*y1-x1*y2;
			double A2=y4-y3;	double B2=x3-x4;	double C2=x4*y3-x3*y4;
			double x0=((C1*B2)-(C2*B1))/((A2*B1)-(A1*B2));
			double y0=(A2*x0+C2)/(-B2);
			//y0=((A1*C2)-(A2*C1))/((A2*B1)-(A1*B2));
			printf("POINT %.2lf %.2lf\n",x0,y0);	//注意double类型,在g++中会出错,提交用c++; 
		}
	}
	printf("END OF OUTPUT\n");
	return 0;
}




知识的定义与分类体系详解 - 从零基础到专业理解 阅读详情

相关推荐

【Cadence】stb仿真和ac仿真——以一个简单的全差分反相放大器仿真为例

最近在补一些仿真方法学的问题,以及一些一直以来都有点模糊的概念,简单记录一下。搭建一个以两个CMOS反相器构成的全差分放大器(28nm工艺,PMOS和NMOS尺寸一致)激励的设置方便共模和差模仿真用同一个TB(这里有一个问题:这个放大器需要在开环下仿真还是闭环下?哪些放大器应用在开环,哪些闭环?这种应用场景不同会导致需要仿真得到开环还是闭环增益,或者环路增益?(我知道放大器在设计的时候肯定都是闭环应用的多,但是什么时候没必要闭环应用?光验证ac和stb仿真是否一样的话有必要有回路吗?

weixin_44951108的博客 5万+

poj 1269 Intersecting Lines

Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u [Submit]

codeStone 1019

Opencv学习-仿射变换与透视变换(几何变换)1

• 一、定义 变换是指对图像进行拉伸、收缩、扭曲和旋转等几何操作。对于平面区域有两种方式的几何转换:一种是基于23矩阵进行的变换,被称为仿射变换;一种是基于33矩阵进行的变换,被称为透视变换。也可被称为平面变换和空间变换。因为仿射变换需要找到3个映射点,三点确定一个平面。而透视变换需要确定四个映射点,四点确定一个三维空间。 • 二、Opencv中的函数定义 由于Opencv中都已封装好函数,变换的...

勉強 583

Intersecting Lines(POJ-1269)

Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, ...

qq_40634175的博客 1079

Flutter 直接调用so动态库,或调用C/C++源文件内函数

我把 .so 文件尝试放过好几个目录/lib/,最终都会报这个错误,现在才知道库文件需要放在你根本想象不到的地方!!!尝试了一些方法还是不行后我放弃了 ffi,想着用 Flutter 的 MethodChannel 桥接 android/ios 原生,再让原生去调 native 层。一顿操作把Android端的搞定了,当然中间涉及到 Kotlin和C++ 层的数据类型映射的痛苦,而且业务函数也不像一个 helloworld 那么简单,别提有多痛苦了。

开发以大橘为重 8352

6、直流微电网中恒功率负载(CPL)的稳定性分析与控制策略

本文探讨了直流微电网中恒功率负载(CPL)带来的稳定性问题,并深入分析了其影响机制及相应的缓解策略。文章首先通过小信号模型和非线性分析揭示了CPL对系统稳定性的影响,接着讨论了被动稳定方法的优缺点,最后重点介绍了基于时间的方法和几何控制器等控制策略。这些方法各有优劣,在实际应用中需结合具体需求选择合适方案,以实现直流微电网的稳定运行。

star的博客 227

UVA - 378 Intersecting Lines【基础计算几何】

【题目描述】 We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) in...

inv0ker的博客 298

YOLOv8改进目录一览 | 涉及卷积层、轻量化、注意力、损失函数、Backbone、SPPF、Neck、检测头等全方位改进

1️⃣本专栏已更新150多种不同的改进方法,所使用并改进的每一个模块均包含详细的模块分析、原理讲解、个人总结、多种改进方式以及完整的修改流程,所有改进100%可直接运行。2️⃣所有改进点均为近三年顶会,顶刊提出的先进算法,将其融入到中,紧跟学术热点,适应不同的任务场景。3️⃣团队内发表数篇SCI论文,熟悉完整的发表流程,订阅专栏即可进群享受模型训练、模型改进、论文写作、投稿选刊,从入门到论文的各种答疑内容。4️⃣专栏内容会持续更新,最近更新时间:2024-12-24。项目介绍在大家购买专栏后,加入学

Limiiiing的博客 1万+

poj 1269 Intersecting Lines(直线相交)

Intersecting Lines Time Limit:1000MS Memory Limit:10000K Total Submissions:8637 Accepted:3915 Description We all know that a pair of distinct points on a plane defi...

weixin_34293141的博客 250

【某音电商】protobuf聊天协议逆向

某音电商私信、聊天消息protobuf协议逆向分析与解析

吴秋霖的博客 2315

【Python办公】剪贴板记录工具(记录文本 + 图片防重复)

本文介绍了一个用Python开发的剪贴板记录工具,能够自动记录复制过的文本和图片内容。该工具使用tkinter构建GUI界面,通过后台线程实时监控剪贴板变化,具有文本记录、图片保存(自动去重)功能。核心代码采用pyperclip访问剪贴板,PIL处理图片,hashlib计算图片哈希值实现去重。运行程序后,文本内容直接显示在界面,图片保存为PNG文件并记录路径。工具还提供清空历史记录功能,适合日常办公中需要追踪剪贴板历史的使用场景。

weixin_42636075的博客 240

poj 1269 Intersecting Lines (判断两条直线的状态)

题目连接:http://poj.org/problem?id=1269 题目思路:给出两条直线,给出的方式是两个点。 判断两条直线是平行,重合还是相交,相交的话求出交点。 解题思路:确定两点求直线, 根据直线的参数去判断状态,要注意一些特殊情况,比如平行x,y的直线等。 #include #include double a, b, c, d; double x[

不慌不忙、不急不躁 1087

SAP 基于生产订单行项目外部加工创建采购申请时的一个增强需求

摘要 本文介绍在SAP系统中实现生产订单外协工序自动生成采购申请(PR)时,将指定文本写入PR抬头文本的技术方案。关键点包括: 业务背景:通过CO02事务码将工序标记为外部加工,系统自动生成PR,需在生成时自动写入抬头文本。 技术难点: PR抬头文本存储在STXH/STXL而非EBAN表 标准增强点ME_PROCESS_REQ_CUST在外协场景可能不触发 推荐方案: 使用BAdI ME_REQ_POSTED,在PR过账时点执行 通过Text Object EBANH和Text ID(如B01)写入文本 实

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 624

poj 1269 Intersecting Lines(两直线交点)

http://poj.org/problem?id=1269 Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13425   Accepted: 5977 Description We all know that

大太阳 675

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【计算几何】POJ 1269 Intersecting Lines

POJ 1269 Intersecting Lines【传送门】 Intersecting Lines Time Limit:1000MS Memory Limit:10000K Total Submissions:20497 Accepted:8658 Description We all know that a pair of disti...

lesileqin的博客 221

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

POJ 1269 Intersecting Lines

题目链接 题意: 判断两条直线的关系:相交 平行 重合 代码: #include <stdio.h> #include <cstring> #include <cmath> #include <iostream> #include <queue> #include <map> #include...

168

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

POJ 1269 Intersecting Lines 判断直线间的状态(平行、重合、相交于一点)

Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8593   Accepted: 3900 Description We all know that a pair of distinct points on a plane

z007kt的专栏 875

Poj_1269 Intersecting Lines -判两直线状态(水题、坑OJ)

题意:判直线相交、平行、重合 吐槽:坑OJ,G++WA,C++AC,模版题 /************************************************ Author :DarkTong Created Time :2016/8/3 23:02:25 File Name :Poj_1269.cpp ****...

bannesi6888的博客 146

POJ 1269 Intersecting Lines G++ 分别给出两条直线上的两点求直线关系 背

给出两条直线的端点坐标,判断两条直线是平行、是重叠、还是交于一点。

woniupengpeng的专栏 591

POJ1269 Intersecting Lines(向量基本运算)

冒险寮 【题目大意】 给你四个点的坐标表示两条线段的端点,判断两条线段的位置关系:相交、共线、不相交,如果相交则输出交点坐标。 【输入格式】 第一行一个整数N。 接下来N行,每行8个整数表示4个点的坐标。 【输出格式】 首先输出一行“INTERSECTING LINES OUTPUT”,对于每组询问,如果不相交输出“NONE”,共线输出“LINE”,相交输出两个两位小数表示交点的坐标...

Michael_GLF的博客 209

poj 1269

题目概述给定两条直线上各2个点,这4个点互不重合,问两条直线的位置关系是重合,平行,或相交,若相交则求出交点时限1000ms/3000ms输入第一行正整数times,其后times行,每行8个整数,分别代表第一条直线上两个点的坐标和第二条直线上两个点的坐标限制1<=times<=10;-1000<=坐标中的数字<=1000输出第一行为字符串INTERSECTING LINES OUTPUT,其后ti

[CHN]liurui 345

poj 1269 Intersecting Lines[直线的关系]

题目链接: poj 1269

985
上一篇: poj 3304 Segments(线段与直线相交)
下一篇: 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem
Singular__point
博客等级 码龄10年 38粉丝 160原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值