POJ 1066 Treasure Hunt(线段相交判断)

hdu1066 阶乘最后一个非0数 你只有非常努力,才能看起来毫不费力。 收获: 1:不要在函数里面(尤其是递归函数里面)定义较大空间的变量,可能会爆栈!!!!可能会出现未知错误!!!       不要在函数里面(尤其是递归函数里面)定义较大空间的变量,可能会爆栈!!!!可能会出现未知错误!!!       不要在函数里面(尤其是递归函数里面)定义较大空间的变量,可能会爆栈!!!!可能会出现未知错误!!! 2:一种判断数据... 阅读详情
Treasure Hunt
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 7040 Accepted: 2907

Description

Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technology they are able to determine that the lower floor of the pyramid is constructed from a series of straightline walls, which intersect to form numerous enclosed chambers. Currently, no doors exist to allow access to any chamber. This state-of-the-art technology has also pinpointed the location of the treasure room. What these dedicated (and greedy) archeologists want to do is blast doors through the walls to get to the treasure room. However, to minimize the damage to the artwork in the intervening chambers (and stay under their government grant for dynamite) they want to blast through the minimum number of doors. For structural integrity purposes, doors should only be blasted at the midpoint of the wall of the room being entered. You are to write a program which determines this minimum number of doors. 
An example is shown below: 

Input

The input will consist of one case. The first line will be an integer n (0 <= n <= 30) specifying number of interior walls, followed by n lines containing integer endpoints of each wall x1 y1 x2 y2 . The 4 enclosing walls of the pyramid have fixed endpoints at (0,0); (0,100); (100,100) and (100,0) and are not included in the list of walls. The interior walls always span from one exterior wall to another exterior wall and are arranged such that no more than two walls intersect at any point. You may assume that no two given walls coincide. After the listing of the interior walls there will be one final line containing the floating point coordinates of the treasure in the treasure room (guaranteed not to lie on a wall).

Output

Print a single line listing the minimum number of doors which need to be created, in the format shown below.

Sample Input

7 
20 0 37 100 
40 0 76 100 
85 0 0 75 
100 90 0 90 
0 71 100 61 
0 14 100 38 
100 47 47 100 
54.5 55.4 

Sample Output

Number of doors = 2 


题意:穿墙中点出来,最少要穿几道墙

思路:枚举起点终点,求跟多少直线相交

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define ms(a,b)memset(a,b,sizeof(a))
#define eps 1e-10
#define inf 1e8

int n,m,cntl,cntp;
int Map[500][500];

double add(double a,double b)
{
    if(abs(a+b)<eps*(abs(a)+abs(b))) return 0;
    return a+b;
}

struct P
{
    double x,y;
    P(){}
    P(double x,double y): x(x),y(y){}
    P operator + (P p)
    {
        return P(add(x,p.x),add(y,p.y));
    }
    P operator - (P p)
    {
        return P(add(x,-p.x),add(y,-p.y));
    }
    P operator *(double d)
    {
        return P(x*d,y*d);
    }
    double dot (P p)
    {
        return add(x*p.x,y*p.y);
    }
    double det(P p)
    {
        return add(x*p.y,-y*p.x);
    }
}p[35],q[35],inter[500];

bool on_seg(P p1,P p2,P q)
{
    return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<0;
}
bool bianjieon_seg(P p1,P p2,P q)
{
    return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;
}
P intersection(P p1,P p2,P q1,P q2)
{
    return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
}

bool xiangjiao(P p1,P p2,P p3,P p4)
{
    if((p1-p2).det(p3-p4)==0)
    {
        return false;
    }
    P r=intersection(p1,p2,p3,p4);
    if(on_seg(p1,p2,r)&&on_seg(p3,p4,r))
        return true;
    return false;
}
bool bianjiexiangjiao(P p1,P p2,P p3,P p4)
{
    if((p1-p2).det(p3-p4)==0)
    {
        return false;
    }
    P r=intersection(p1,p2,p3,p4);
    if(bianjieon_seg(p1,p2,r)&&bianjieon_seg(p3,p4,r))
        return true;
    return false;
}


int main()
{
    while(~scanf("%d",&n))
    {
        int cnt=0;
        for(int i=0;i<n;i++)
            scanf("%lf%lf%lf%lf",&p[i].x,&p[i].y,&q[i].x,&q[i].y);
        p[n].x=0;p[n].y=0;q[n].x=0;q[n].y=100;
        p[n+1].x=0;p[n+1].y=100;q[n+1].x=100;q[n+1].y=100;
        p[n+2].x=100;p[n+2].y=100;q[n+2].x=100;q[n+2].y=0;
        p[n+3].x=100;p[n+3].y=0;q[n+3].x=0;q[n+3].y=0;
        double xx,yy;
        scanf("%lf%lf",&xx,&yy);
        P st=P(xx,yy);
        for(int i=0;i<=n+3;i++)
            for(int j=i+1;j<=n+3;j++)
        {
            if(bianjiexiangjiao(p[i],q[i],p[j],q[j]))
            {
                if(i>=n||j>=n)
                inter[cnt++]=intersection(p[i],q[i],p[j],q[j]);
            }
        }
        int ans=999999;
        for(int i=0;i<cnt;i++)
        {
            int tmp=0;
            for(int j=0;j<n;j++)
            {
                if(xiangjiao(st,inter[i],p[j],q[j]))
                    tmp++;
            }
            ans=min(tmp,ans);
        }
        printf("Number of doors = %d\n",ans+1);

    }
    return 0;
}


工业质检终极方案:C#上位机融合 YOLO+Blob分析(一站式尺寸测量+缺陷检测) 本次上位机界面严格遵循工业现场操作规范简洁、直观、按钮大、文字清晰、参数可视化调节,操作人员为车间工人/质检员,无需复杂操作,所有功能一目了然。所有控件均为WinForms原生控件,拖拽即可完成布局,无任何自定义控件,开发效率拉满,核心布局永久复用本次实战完成的C#上位机+YOLO+Blob融合质检方案,是工业规则零件全尺寸质检的终极落地方案,完美解决了单一检测方案的所有短板,具备以下不可替代的工业价值。 阅读详情

相关推荐

基于TL431与MOSFET的高效过压保护电路设计详解

本文详细解析了基于TL431与MOSFET的高效过压保护电路设计。通过TL431精准监测电压,驱动MOSFET作为主开关,实现快速可靠的电源保护。文章涵盖电路原理、参数计算、性能优化及实战调试要点,为电子设备提供了一套经典且成本低廉的过压保护解决方案。

weixin_29215391的博客 825

hdu1066题讲解

/*1066:为了把0去掉,我们把所有的因数2和5都提出来,放到最后再处理。N!中的N个相乘的数可以分成两堆:奇数和偶 数。偶数相乘可以写成(2^M)*(M!),M=N DIV 2。M!可以递归处理,因此现在只需讨论奇数相乘。考虑1*3*5*7*9 *11*13*15*17*

700

基于C#的软PLC梯形图编辑器开发实战

本文详细介绍了基于C#开发软PLC梯形图编辑器的实战过程。文章从核心数据结构设计入手,阐述了如何利用C#的面向对象特性构建梯形图元素模型,并实现了图形编辑、指令表输入、逻辑连接拓扑重建等关键功能。重点剖析了模拟PLC执行引擎的扫描周期与能流传递算法,让梯形图逻辑在PC上“活”起来。最后探讨了定时器指令实现、性能优化及项目集成等进阶内容,为工业自动化软件集成提供了灵活高效的解决方案。

weixin_28314575的博客 408

HDU 1066 阶乘最后非零位 应用acm模板

模板的第一程序,直接应用。 #include #include #define maxn 10001 const int mod[20]={1,1,2,6,4,2,2,4,2,8,4,4,8,4,6,8,8,6,8,2}; int lastdigit(char buf[]) { int len=strlen(buf),a[maxn],i,c,ret=1; if(

vsooda的专栏 1838

Java对接(BSC)币安链 | BNB与BEP20的开发实践(三)水龙头 WEB3

这一节我们讲一个币安测试链如何获取到BNB、USDT等BEP20数字货币(水龙头)来让我们前期测试开发。如图:我们将创建的地址填入相应输入框,来获取到测试BNB以及其他BEP20数字币。发币可能需要交易等待,请耐心等待即可,交易完成后,币会到达您的地址内。上一节我们用代码来实现BNB转账、BEP20转账、链上交易监控。2.MetaMask(小狐狸)浏览器插件 🪜。使用EDGE浏览器可以在浏览器直接打开。使用Chrome浏览器,请使用🪜打开。基本工作就绪后,即可进行开发测试。3. 测试区块链浏览器 🪜。

大猩猩的专栏 2801

保姆级教程:用Docker一键部署vLLM大模型推理服务(附常见报错解决方案)

本文提供了一份详细的Docker化vLLM大模型推理服务部署指南,涵盖从环境准备到性能调优的全流程。通过容器化技术解决大语言模型部署中的显存利用率、吞吐量等核心问题,并附常见报错解决方案,帮助开发者快速构建高效、可扩展的AI推理服务。

weixin_29248313的博客 504

HDU1066--高精度求阶乘最后非零位

题目:Last non-zero Digit in N!   #include #include #define maxn 10001 const int mod[20]={1,1,2,6,4,2,2,4,2,8,4,4,8,4,6,8,8,6,8,2}; int lastdigit(char buf[]) { int len=strlen(buf),a[maxn],

ACdreamer 1612

地震勘探原理---地震预处理

3.1 为什么说要对数据进行振幅补偿?具体来说,地震波在传播过程中会遇到各种各样的地质条件,例如不同的岩层、土壤、水层等,这些介质的密度、速度等特性不同,因而对地震波的能量消耗也有所不同。在传播距离较远的情况下,能量损失可能会导致接收到的地震信号振幅变小。相反,在传播距离较近的情况下,能量损失可能较小,导致接收到的地震信号振幅变大。如果不对数据进行振幅补偿,这种振幅不均衡会导致地震数据分析和解释的误差和不确定性增加,可能产生错误的结论。

DARRENANJIAN的博客 3292

HDU1066 Last non-zero Digit in N!【大数+模除】

Last non-zero Digit in N! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10306 Accepted Submission(s): 2474 Problem Description The express...

海岛Blog 744

HFSS实战项目——基片集成波导(SIW)带通滤波器

设计了一款直接耦合的SIW带通滤波器, 采用直接耦合的形式, 工作频率覆盖19~21 GHz, 通带内插入损耗小于1.5 dB, 回波损耗小于-20 dB, 带外抑制特性良好.

2401_87464239的博客 4926

华为昇腾(Ascend)开发考试原题目解析 (2024) (题库一)——HCIP-AI-Ascend Developer——第一部分

给出一段代码如下,以下哪个选项描述错误?...A.中的语句由 MindSpore 接管,有语法限制B. 算子在中定义,并用来建立网络C.__init__()中的语句由 Python 解析执行D. 网络定义必须继承基类nn.Cell正确答案: B__init__()用于定义算子和网络层。所有需要用到的层(如卷积层、全连接层等)都应该在这里进行实例化。这部分代码由Python解释器执行。用于构建前向计算图。它调用在__init__()中定义好的算子和层来描述数据的流向。

qq_38334677的博客 1070

[poj 1066][洛谷 UVA754] Treasure Hunt {判断两条线段是否相交}

题目 https://www.luogu.org/problemnew/show/UVA754 解题思路 代码 #include&amp;amp;amp;lt;cstdio&amp;amp;amp;gt; #define db double using namespace std; const int maxn=50; const int Inf=0x3f3f3f3f; const db Err=1e-8; inline int ...

Nowed 602

Playwright爬虫实战:破解动态网页懒加载与无限滚动

本文介绍了使用Playwright处理懒加载和无限滚动页面的完整解决方案。摘要如下: 问题分析:传统爬虫无法获取JS动态渲染内容,Playwright能模拟真实浏览器行为解决此类问题。 核心原理: 懒加载:资源延迟加载,滚动触发 无限滚动:滚动到底部异步加载新内容 技术方案: 分段滚动页面并等待加载 动态监测页面高度变化 合理设置等待和终止条件 代码实现: 提供图片懒加载和无限滚动列表的完整可运行代码 包含异常处理和性能优化建议 关键优势: 比传统爬虫更可靠 支持复杂交互场景 完善的错误处理机制 该方法已在

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 529

POJ_1066_Treasure Hunt_判断线段相交

POJ_1066_Treasure Hunt_判断线段相交 Description Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technolo...

195

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

poj 1066 Treasure Hunt(判断线段相交)

DescriptionArcheologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technology they are able to determine that the

退役的铜牌狗 361

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

POJ 1066 Treasure Hunt 判断线段相交(求交点个数)

Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4875   Accepted: 2022 Description Archeologists from the Antiquities and Curios Museum (ACM)

z007kt的专栏 1106

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

POJ 1066 Treasure Hunt(思维+线段相交判断)

思路:枚举每一个端点,与终点形成线段,与其它线段进行比较,如果有相交,说明要多炸一道墙。同时要将四个角落也加进端点中。这道题比较考思维,但是一般都是要枚举端点的,这一点可以列入这些题型的考虑中。...

weixin_48024524的博客 212

POJ 1066 Treasure Hunt (判断线段相交个数)

Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6138   Accepted: 2548 Description Archeologists from the Antiquities and Curios Museum (ACM) have

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

POJ 1066 Treasure Hunt 线段相交判断

判断以宝藏的坐标和中点的坐标为线段的点是否与墙相交,求最少相交的墙的数量 中点算出来,枚举中点和墙 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define eps 1e-8...

weixin_34185320的博客 85

poj 1066 Treasure Hunt 线段相交判断

http://poj.org/problem?id=1066 宝藏在一个矩形的内部,矩形内有纵横交错的墙形成多个房间,求最少炸掉多少道墙可到达宝藏所在的房间,宝藏不会在墙上,炸点必须在墙的中间点上,不会超过两个的墙相交以一点。 若起点和宝藏点连线的线段和某直线相交,那么无论你怎么绕你都要穿过这条直线才能到达宝藏点。所以我们可以这样做:枚举矩形边上的所有点做为起点,(不需要...

weixin_30725467的博客 88

poj 1066 Treasure Hunt(判断线段相交)

Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4145   Accepted: 1708 Description Archeologists from the Antiquities and Curios Museum (ACM) ha

志当存高远 996

Poj 1066 Treasure Hunt && Nyoj 83 迷宫寻宝(二)判断线段相交

题目链接:poj 1066         nyoj 83

1125

POJ 1066--Treasure Hunt(判断线段相交)

Treasure Hunt Time Limit:1000MS Memory Limit:10000K Total Submissions:7857 Accepted:3247 Description Archeologists from the Antiquities and Curios Museum (ACM) have...

weixin_33737774的博客 99
上一篇: POJ 2653 Pick-up sticks(判断线段相交)
下一篇: POJ 1410 Intersection(判断线段交和点在矩形内)
Sitlos
博客等级 码龄10年 20粉丝 212原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值