poj2653 Pick-up sticks 计算几何 线段相交

滑模控制算法——基本原理(附MATLAB程序) 选择一个滑模面和是设计参数。是滑模面函数,通常我们希望系统状态在的面上滑动。我们以一个简单的二阶系统作为示例,其状态空间方程为:是系统矩阵是输入矩阵是输出矩阵假设我们的系统如下:滑模控制算法的核心在于设计合适的滑模面和控制律,并分析系统在滑模面上的稳定性。通过上述公式和步骤,可以有效地设计滑模控制器,以处理具有非线性和不确定性的动态系统。总的来说,滑模控制算法因其鲁棒性和灵活性在处理复杂控制问题中表现出色,但在实际应用中需要精心设计以克服抖振现象和其他潜在问题。BuxuABDC。 阅读详情

Pick-up sticks
Time Limit: 3000MS Memory Limit: 65536K
Total Submissions: 11634 Accepted: 4387

Description

Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he wants to know all the sticks that are on top. Stan sticks are very, very thin such that their thickness can be neglected.

Input

Input consists of a number of cases. The data for each case start with 1 <= n <= 100000, the number of sticks for this case. The following n lines contain four numbers each, these numbers are the planar coordinates of the endpoints of one stick. The sticks are listed in the order in which Stan has thrown them. You may assume that there are no more than 1000 top sticks. The input is ended by the case with n=0. This case should not be processed.

Output

For each input case, print one line of output listing the top sticks in the format given in the sample. The top sticks should be listed in order in which they were thrown. 

The picture to the right below illustrates the first case from input.

Sample Input

5
1 1 4 2
2 3 3 1
1 -2.0 8 4
1 4 8 2
3 3 6 -2.0
3
0 0 1 1
1 0 2 1
2 0 3 1
0

Sample Output

Top sticks: 2, 4, 5.
Top sticks: 1, 2, 3.

Hint

Huge input,scanf is recommended.




只要(c x b) * (d x b) <= 0 && (e x a) * (f x a) <= 0,就说明两线段相交



#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>

using namespace std;

struct line {
	double x1, y1, x2, y2;
}e[100005];

int n;
bool inter[100005];

bool Intersect(line a, line b) {
	double cxb = (a.x2 - b.x1) * (b.y2 - b.y1) - (a.y2 - b.y1) * (b.x2 - b.x1);
	double dxb = (a.x1 - b.x1) * (b.y2 - b.y1) - (b.x2 - b.x1) * (a.y1 - b.y1);
	double exa = (b.x1 - a.x1) * (a.y2 - a.y1) - (b.y1 - a.y1) * (a.x2 - a.x1);
	double fxa = (b.x2 - a.x1) * (a.y2 - a.y1) - (a.x2 - a.x1) * (b.y2 - a.y1);
	if ((fabs(cxb * dxb) < 1e-10 || cxb * dxb < 0) && (fabs(exa * fxa) < 1e-10 || exa * fxa < 0)) {
		return true;
	}
	return false;
}

int main()
{
	while (~scanf("%d", &n) && n) {
		memset(inter, false, sizeof(inter));
		for (int i = 0; i < n; i++) {
			scanf("%lf%lf%lf%lf", &e[i].x1, &e[i].y1, &e[i].x2, &e[i].y2);
		}
		int cou = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (Intersect(e[i], e[j])) {
					inter[i] = true;
					cou++;
					break;
				}
			}
		}
		cou = n - cou;
		printf("Top sticks: ");
		for (int i = 0, c = 0; i < n; i++) {
			if (!inter[i]) {
				c++;
				if (c == cou) {
					printf("%d.\n", i + 1);
					break;
				}
				else {
					printf("%d, ", i + 1);
				}
			}
		}
	}
	return 0;
}



SPARQL——语义网的查询语言 官方教程:SPARQL 1.1 Query Language 目录0. 前言1. 从`SELECT WHERE{}`开始——熟悉SPARQL的语法1.1 开始最简单的查询——使用SPARQL查询TTL文件1.2 使用SPARQL查询RDF文件2. 开始更复杂的匹配 0. 前言 SPARQL语言主要是面向RDF/OWL的查询语言。从图论的角度来看,查询的过程可以看做子图匹配。本教程按照官方教程的脉络,采用python实现。在python中,操作本体的库是rdflib,这个库非常好用,rdflib的官方教程. 阅读详情

相关推荐

ADSP-21565的SigmaStudio图形化编程实战:从FW工程改造到音频通道打通

本文详细介绍了如何将ADSP-21569的SigmaStudio图形化编程固件工程改造,以适配ADSP-21565的纯片内SRAM内存架构。通过修改内存映射和链接文件,打通了音频输出通道,并成功利用SigmaStudio进行图形化编程,实现了从白噪声生成到音频输出的完整验证流程。

weixin_29169505的博客 391

算法训练 Sticks

算法训练 Sticks

m0_53270352的博客 705

移相变压器Simulink建模与HVDC系统仿真实践

移相变压器是电力电子领域实现精确相位调节的核心设备,其通过特殊绕组设计改变输出电压相位角,在解决环网潮流不均、阻尼功率振荡等场景具有关键作用。本文基于MATLAB/Simulink环境,详细解析移相变压器的建模原理与技术实现,包括磁路耦合特性模拟、参数计算方法和控制策略设计。针对HVDC高压直流输电和FACTS柔性交流输电系统等典型应用,提供仿真模型搭建技巧与问题排查指南,特别涵盖新能源并网场景下的相位调节优化方案。通过实测数据验证,所建模型在稳态精度和动态响应方面均满足工程要求,为电力系统稳定性分析提供有

weixin_28278377的博客 280

【跨立实验】poj2653

Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no ...

SummerDream 546

从Excel到Power Pivot:构建你的第一个商业智能分析模型

本文详细介绍了如何从Excel升级到Power Pivot,构建你的第一个商业智能分析模型。通过激活Power Pivot功能、导入数据、建立表关系、创建智能度量值以及打造交互式仪表盘,帮助用户高效处理百万行级别的数据,实现数据自动关联和动态分析,大幅提升商业决策效率。

weixin_30629653的博客 262

PVE 9.0 保姆级安装及优化教程(换源、网络配置、远程唤醒等)【基础篇】

最近,Proxmox VE 推出了基于 Debian 13 的 9.0 版本。正巧我手头有一台闲置的老电脑,与其闲置,不如装上 PVE,让它化身 All in One,继续发挥它的余热。G4560 算是一颗 NAS 神 U,十几元的售价就能有双核四线程,比起什么 J1900 不知道强到哪里去了,尽管定位上是奔腾处理器,但性能甚至能和同代的酷睿 i3-7100 掰掰手腕,并且它还自带 HD 610 的核显,对于解码的支持也还不错。

zc_mk的博客 7557

蓝桥杯算法训练sticks

蓝条杯算法训练stick

fuzekun的博客 934

保姆级教程:用PyBullet在Windows/Mac上快速搭建你的第一个机器人仿真环境(附避坑指南)

本教程详细介绍了如何使用PyBullet在Windows和Mac上快速搭建机器人仿真环境,包括Python环境配置、依赖安装避坑指南、首个机械臂仿真实现及性能优化技巧。通过分步指导和实战代码,帮助初学者轻松入门机器人仿真技术。

weixin_42526087的博客 424

试题 算法训练 Sticks(dfs+剪枝)

思路:dfs+剪枝算法 1)要确定好target,也就是um of sticks的约数且要大于最大的木棍 2)木棍排序,从大到小排 3)在满足一个target的任务中,因为顺序排列,所以重复元素,前面没选的,这一次也不选,剪枝 4)在满足一个target的任务中,如果当前最长的木棍满足失败,则整条枝失败,因为我们从小到大排列,会越来越小 #include<bits/stdc++.h> using namespace std; #define ul unsigned long #define .

蜡笔小新冲鸭!!! 538

Allegro 给元器件PCB封装库添加3D模型详细步骤

从上面视图可以看到模型跟PCB 库的方向是对了,但是位置偏下,且在PCB封装库后面,我们下面需要做的就是把模型往上移、往前移。首先将元器件3D模型文件放在封装库的目录下(也可以单独新建一个模型库文件夹),注意3D文件必须是Step格式。Transparent: 选择透视的对象,可以是模型、也可以是PCB封装,或者两种都透视。在左边搜索要添加的3D模型的文件(注意是在* 星号前面输入文件名),按回车即可找到。同样的,接下来需要往Y 负方向移,即左移,一边调整一边观察视图。

sinat_15677011的博客 3703

【数据结构】考点二十八 : 二叉树的概念:二叉树的度、完全二叉树、满二叉数结点数、哈夫曼结点数、完全二叉树的深度

二叉树(Binary Tree)是一种常见的数据结构,它或者为空(null),或者由一个根节点(root node)和两个子树(left subtree 和 right subtree)组成,这两个子树又分别是一棵二叉树。二叉树的每个节点最多有两个子节点,通常称为左子节点(left child)和右子节点(right child)。

超越的博客 1750

蓝桥杯 算法训练 Sticks

问题描述   George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he h...

小郁同学 674

4、LTE无人机认证:保障通信安全的新方案

本文针对LTE网络中无人机通信存在的安全风险,提出了一种基于可信第三方GCS的新型认证协议。该协议通过非对称加密和哈希函数保护IMSI等敏感信息,防止身份泄露、中间人攻击、拒绝服务攻击和位置追踪等威胁。利用Scyther工具对协议进行形式化分析,验证了其在机密性、一致性和活性等方面的安全属性,证明该方案能有效提升无人机在LTE网络中的通信安全性与隐私保护能力。

pink的博客 75

POJ 2653 Pick-up sticks [线段相交]【计算几何】

题目连接:http://poj.org/problem?id=2653————————————————————————.Pick-up sticks Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 12353 Accepted: 4660 DescriptionStan has n sticks of

Tabris的博客 575

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

POJ 2653 Pick-up sticks(计算几何,判断线段相交)

解题思路: 暴力循环,如果一个线段后面的所有线段都不和它相交,则这个线段是top的。 #include #include #include #include #include #include #include #include #include #include #define LL long long using namespace std; const int MAX

蘑菇--走在通往梦想的道路上。 567

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

POJ 2653 Pick-up sticks [计算几何,线段相交]

题目 Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last

sehnsucht 213

POJ 2653 Pick-up sticks 计算几何 线段相交

计算几何的题目   庆幸不用判断共线  题目说了    第一种方法是读入一个处理一个   结果超时了 第二种方法是读完了后再处理    AC     同样是暴力求解  但是也得讲究技术啊 TLE代码: #include #include #include #include #define Max 100005 #define eps 1e-10 using namespace s

泪无痕 826

POJ2653---Pick-up sticks (基础计算几何:线段相交问题)

【题目来源】:https://vjudge.net/problem/POJ-2653 【题意】 这道题叙述了一个游戏的规则以及玩法,从手里依次扔出雪糕棍,在地上会可能就会堆起来,然后挑出棍上没有棍的棍(好拗口。。。)。 【思路】 这道题很简单的线段相交问题,但是时间负责度问题上,我就想不明白了100000*100000怎么可以3s过。。。但是由于本身才学疏浅,所以只好暴力交了一发,心中无限郁

Crazy 515

POJ 2653 Pick-up sticks

POJ 2653 Pick-up sticks Description Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is...

旺崽的博客 2990

计算几何——Pick-up sticks(线段相交)

题目链接:poj.org/problem?id=2653 Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these...

mumei的博客 464

【计算几何】POJ 2653 Pick-up sticks

POJ 2653 Pick-up sticks 【传送门】 Time Limit:3000MS Memory Limit:65536K Total Submissions:15915 Accepted:5999 Description Stan has n sticks of various length. He throws them one ...

lesileqin的博客 277

poj2653Pick-up sticks【判断线段相交】

Language:Default Pick-up sticks Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 11110   Accepted: 4155 Description Stan has n sticks

走一步再走一步 1002

POJ 2653 Pick-up sticks (判断线段相交)

Pick-up sticks Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 11329   Accepted: 4247 Description Stan has n sticks of various length. He throws them one at a

滴水穿石,慢慢积累,总会有成果 1359

poj 2653 Pick-up sticks 计算几何

poj 2653 Pick-up sticks 计算几何 Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan

klc的博客 396

UVA 10902 POJ 2653 Pick-up sticks【线段规范相交】【图】

题目大意:给出火柴(线段)的起点终点,有童鞋无聊按输入顺序扔火柴,求最后所有没有被其他火柴压住的火柴序号。 解题策略:第一反应想到的算法很简单:                     1,火柴只能被后来的火柴可能压住 火柴只能和后来的火柴“相交” ,之前的火柴不考虑;                     2,“相交”   "规范相交",这里是关键;(详见下图)

less is more 1533

Pick-up sticks POJ2653(线段相交判断)

Pick-up sticksPOJ - 2653 Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that i...

勉強しているユキさんです 266

Pick-up sticks POJ - 2653

Pick-up sticks POJ - 2653 分类:计算几何+线段相交** 题目: Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sti...

DeathYmz的博客 453
上一篇: poj2996 Help Me with the Game 结构体多级排序 桶排序
下一篇: hdu1166 敌兵布阵 线段树 单点更新区间查询
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址