HDU 1392 Surround the Trees(求凸包周长)

中国主要湖泊水库面状矢量边界图层ArcGIS应用实战:从数据获取到专题图制作 本文详细介绍了中国主要湖泊水库面状矢量边界图层在ArcGIS中的实战应用,从数据获取到专题图制作的全流程。涵盖官方数据源、科研机构共享数据及商业平台的选择,以及ArcGIS中的数据处理、拓扑错误修正和专题图设计技巧,帮助用户高效完成湖泊水库的空间分析与可视化。 阅读详情

题目链接:
HDU 1392 Surround the Trees
题意:
求凸包周长。
分析:
需要注意只有一个点时答案是0,只有两个点时答案是两点间距离。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
const int MAX_N=1100;

int n;

struct Point{
    double x,y;
    Point () {}
    Point (double x,double y) : x(x),y(y){
    }
    Point operator + (const Point& rhs) const {
        return Point(x+rhs.x,y+rhs.y);
    }
    Point operator - (const Point& rhs) const {
        return Point(x-rhs.x,y-rhs.y);
    }
    Point operator *(const double d) const {
        return Point(d*x,d*y);
    }
    double dis(const Point& rhs) const {
        return sqrt((x-rhs.x)*(x-rhs.x)+(y-rhs.y)*(y-rhs.y));
    }
    double cross(const Point& rhs) const {
        return (x*rhs.y-y*rhs.x);
    }
}point[MAX_N],vertex[MAX_N];

bool cmp_x(const Point& a,const Point& b)
{
    if(a.x==b.x) return a.y<b.y;
    else return a.x<b.x;
}

int Andrew()
{
    sort(point,point+n,cmp_x);
    int k=0;
    for(int i=0;i<n;i++){
        while(k>1&&(vertex[k-1]-vertex[k-2]).cross(point[i]-vertex[k-1])<=0) k--;
        vertex[k++]=point[i];
    }
    int m=k;
    for(int i=n-2;i>=0;i--){
        while(k>m&&(vertex[k-1]-vertex[k-2]).cross(point[i]-vertex[k-1])<=0) k--;
        vertex[k++]=point[i];
    }
    if(k>1) k--;
    return k;
}

void solve()
{
    int total=Andrew();
    //printf("total=%d\n",total);
    double perimeter=0;
    for(int i=0;i<total;i++){
        perimeter+=vertex[i].dis(vertex[(i+1)%total]);
    }
    printf("%.2f\n",perimeter);
}

int main()
{
    freopen("Gin.txt","r",stdin);
    while(~scanf("%d",&n)&&n){
        for(int i=0;i<n;i++){
            scanf("%lf%lf",&point[i].x,&point[i].y);
        }
        if(n==1){
            printf("0\n");
        }else if(n==2){
            printf("%.2f\n",point[0].dis(point[1]));
        }else {
            solve();
        }
    }
    return 0;
}
在Simulink中搭建一个基于IoT设备间通信协议栈的仿真模型 物联网(IoT)设备间的通信协议栈仿真对于理解不同层级的协议如何协同工作,以及优化网络性能至关重要。通过Simulink结合MATLAB的强大功能,我们可以模拟和分析从物理层到应用层的完整通信过程。下面详细介绍如何使用Simulink进行IoT设备间通信协议栈的仿真。 阅读详情

相关推荐

用ST25DV芯片+KiCad快速设计NFC标签天线:参数计算/脚本生成/实测优化全流程

本文详细介绍了使用ST25DV芯片和KiCad工具设计NFC标签天线的全流程,包括参数计算、脚本生成和实测优化。通过解析芯片等效工作原理和设计思路,帮助开发者避开常见陷阱,实现高效、可量产的天线设计。文章还提供了Python计算工具和KiCad自动化脚本,大幅提升设计效率和成功率。

jj890的博客 761

HDU1392Surround the Trees(凸包判断 + 求周长)

http://www.cnblogs.com/hmhard/archive/2013/02/05/2893035.html这是判断三角区域那块写的不好。 判断凸包的方法: 1、将所有点按照y从小到大排序,x从小到大排序 2、现将前两个点放入栈中,然后判断下一个点在这两个点组成的线段的左边还是右边,左边的话,直接加入栈中, 如果在右边的话,就不行了,为了让这个点行,所以栈顶元素出栈...

apk6909的博客 157

【深度学习基础】Temporal Fusion Transformer

从下向上看:全连接(Dense) → ELU(指数线性激活函数(比relu好点,有利于模型收敛)) → 全连接(Dense) → 门控线性单元(Gate)(Gated Linear Units (GLUs)) → Layernorm。:一方面,它可以进行静态上下文变量和动态变量的融合,另一方面,通过门控进行了特征选择操作,门控体现在GLU(门控线性单元)中,用了sigmoid控制信息的通过程度,具有良好的适应性,能够自动选择有效信息,自适应地调整网络复杂性。输入:主输入,可选的上下文向量c。

weixin_41838721的博客 1242

HDU 1392 Surround the Trees(计算几何,求凸包周长)

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11188    Accepted Submission(s): 4347 Problem Description There are

超越自我就是成功 398

从零开始讲DDR(5)——读懂Datasheet

对于开发人员来说,需要根据实际场景和使用的需要,使用不同厂家,不同型号的DDR,虽然原理上大同小异,但是还是有一些细节上的需要注意的地方,接触一个新的DDR芯片,首先就是需要找到对应的datasheet,而能都读懂datasheet,也是一个硬件工程师的必备技能。

apple_53311083的博客 5242

LoRa无线通信技术介绍(六)SX127X芯片收发程序讲解

接收LORA芯片SX127X的收发程序。

DT程序员的博客 1755

hdu1392 Surround the Trees (求凸包周长)

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9307    Accepted Submission(s): 3558 Problem Description The

把复杂的事情简单描述 692

GNN-图卷积模型-直推式-2016:GCN【消息传递(前向传播):聚合函数+更新函数】【聚合函数:mean(邻域所有节点取平均值)】【训练更新函数的参数】【空域+频域】【同质图】

图神经网络(GNN):GCN【开山之作】

u013250861的博客 2059

hdu 1392 Surround the Trees(求取凸包并求凸包的周长)

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8414    Accepted Submission(s): 3222 Problem Description There are a

llin-黎辰 531

Android/Linux驱动开发:使用dev_dbg进行设备驱动调试

在本文中,我们将介绍如何使用dev_dbg宏和相关的函数来进行设备驱动调试。函数在该目录下创建了一个名为"debug"的debugfs文件。在这些函数中,您可以执行与您的设备驱动相关的调试操作。函数在该目录下创建了一个名为"debug"的debugfs文件。在这些函数中,您可以执行与您的设备驱动相关的调试操作。的结构体指针,其中包含了我们定义的文件操作函数。的结构体指针,其中包含了我们定义的文件操作函数。在上面的示例中,我们首先通过调用。在上面的示例中,我们定义了。在上面的示例中,我们定义了。

ByteKnight的博客 376

1.2 amdgpu_bo的设计分析 — gem层和ttm层

本文分析了AMD KFD的BO设计架构,重点介绍了DRM子系统中缓冲对象的多层继承关系。文章首先展示了核心继承层次图,包括DRM通用层(drm_gem_object)、TTM内存管理层(ttm_buffer_object)、AMD驱动层(amdgpu_bo)和KFD计算层(kgd_mem)。随后详细解析了drm_gem_object结构体的关键功能,包括用户空间接口管理、内存映射支持、引用计数机制以及DMA-BUF导入/导出功能。

图形/计算GPU的驱动与虚拟化技术分享园地 2575

HDU 1392-Surround the Trees(求凸包周长)

求凸包比较容易是实现的一种方法:Graham扫描算法(基于平面扫描法);                                                   基本过程: 1、寻找极点(x最小的点如果x相同则y最小的点) 2、极角排序(通过叉乘来判断其余点与极点连线的位置,按照逆时针顺序来排序) 3、用数组模拟栈来(因为此过程中需要栈顶和栈顶下一元素,so用数组比较方便获取...

Ordinarv 216

Esp32蓝牙Hid调用方案 http执行设备、鼠标、键盘相关操作

本文主要介绍 Esp32 蓝牙 Hid 相关的多种操作方式,详细的设备、鼠标、键盘相关操作的 http 调用方法。下面是整理出的所有 http 调用方法和 rhino 引擎方式。本机调用的话直接使用http://localhost:8080 如果是局域网调用则使用软件里的地址 比如我的是http://192.168.1.5:8080。文件地址: https://www.123865.com/s/Qtm4jv-xyZbd?使用前需要一块烧录好的ESP32板子并在手机安装好embedded软件用于蓝牙通信。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 579

HDU 1392 Surround the Trees (Graham求凸包周长)

题目链接 题意 : 让你找出最小的凸包周长 。 思路 : 用Graham求出凸包,然后对每条边求长即可。 Graham详解 1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <math.h> 5 #include &...

weixin_30639719的博客 96

数学建模模型总结

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

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

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

HDU 1392.Surround the Trees【凸包(求凸包周长)】【5月10】

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9790    Accepted Submission(s): 3763 Problem Description There a

Mr丶Gao 807

深度学习工具包 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")

hdu 1392:Surround the Trees(计算几何,求凸包周长)

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6812    Accepted Submission(s): 2594 Problem Description There are a lot o...

weixin_33701294的博客 153

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

HDU 1392 Surround the Trees (凸包周长)

题目链接:HDU 1392 Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So at first he must know the minimal required length of the rope...

G19850917的博客 197

HDU - Surround the Trees(凸包周长)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1392Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description There are a lot of trees in an area. A peasant...

ityanger的技术栈 2439

ACM-计算几何之Surround the Trees——hdu1392

ACM 计算几何 Surround the Trees hdu1392 凸包周长

继续激情,继续奋斗。 1900

HDU 1392 Surround the Trees (凸包)

HDU 1392 Surround the Trees (凸包) 题意 给定二维平面nnn个点坐标,求凸包周长。 思路 GrahamGrahamGraham 扫描法,有时间具体写。 代码先贴上 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7; #define mst(a,b) memset(a,b,size

Harris-H的博客 507

HDU1392:Surround the Trees(凸包问题)

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7164    Accepted Submission(s): 2738 Problem Description There a

TOKHE的专栏 1507

hdu 1392 Surround the Trees 凸包周长

Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9486    Accepted Submission(s): 3648 Problem Description There a

EventQueue的博客 638

HDU 1392 Surround the Trees【凸包】

1.题目 题目链接:点这儿! 2.解决方法 在一个二维平面上给出一个点集P,用一根橡皮筋将这些点捆住,形成的也就是一个由P组成的最小多边形,这个凸多边形被称作凸包;求凸包的周长,常见的有Graham扫描法、Andrew算法;后者是前者的改进,本题使用Andrew算法。 Andrew算法:将所有点按照x升序排序,若是x相等,则以y进行升序排序。从最左下方的点开始,求下凸壳;再从最右上方开始,求上凸壳。上下凸壳长度之和即为凸包周长。求凸壳的每一步,尽量将栈最上方两点构成的向量“逆时针旋转”。 3.代码 #inc

kingdom365的博客 220

Surround the Trees HDU1392(二维凸包周长)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1392 题意:求凸包周长 题解:休闲题 代码: # define _CRT_SECURE_NO_WARNINGS #pragma GCC optimize(2) #include <iostream> #include <algorithm> #include <...

- 190

HDU-1392 Surround the Trees(凸包+周长)

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1392 题意:求凸包的周长。 思路:凸包裸题。 #include <cstdio> #include <iostream> #include <cmath> #include <algorithm> using namespace std; const...

birdmanqin的博客 227
上一篇: POJ 3348 Cows(求凸包面积)
下一篇: HDU 2202 最大三角形(求凸包中最大三角形面积)
ramay7
博客等级 码龄11年 64粉丝 464原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值