hdu 2181 哈密顿绕行世界问题(dfs)

手把手教你用ROS2 Humble给PX4无人机写个“画圆”程序:从C++代码到Gazebo仿真全流程 本文详细介绍了如何使用ROS2 Humble和PX4飞控实现无人机圆形轨迹控制,涵盖从环境配置、Gazebo仿真到C++代码实现的完整流程。通过实战教程,读者将掌握轨迹跟踪仿真的核心技术,包括ROS2与PX4的通信接口、圆形轨迹算法设计及Gazebo仿真调试技巧。 阅读详情

题目大意:

        一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。输出路径。 

解题思路:

        直接从起点开始dfs即可。

代码:

#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>

using namespace std;

int path[25][3];
int f[25];
int ans[25],num,m;

void dfs(int now,int length){
    f[now] = false;
    ans[length] = now;
    if(length == 20 && (m == path[now][0] || m == path[now][1] || m == path[now][2])){
        num ++;
        printf("%d: ",num);
        for(int i = 1; i <= 20; i ++){
            printf(" %d",ans[i]);
        }
        printf(" %d\n",m);
        f[now] = true;
        return;
    }
    for(int i = 0; i < 3; i ++){
        if(f[path[now][i]]) dfs(path[now][i],length+1);
    }
    f[now] = true;
    return;
}

int main()
{
    for(int i = 1; i <= 20; i ++){
        cin >> path[i][0] >> path[i][1] >> path[i][2];
        sort(path[i],path[i]+3);
    }
    while(true){
        cin >> m;
        if(m == 0) break;
        memset(f,true,sizeof(f));
        num = 0;
        dfs(m,1);
    }
    return 0;
}


52、Power BI Desktop 数据筛选全攻略 本文全面介绍了Power BI Desktop中各类数据筛选功能的使用方法,涵盖布尔型数据筛选、高级文本筛选、Top N筛选、可视化级别、页面级别和报告级别筛选等核心操作。通过详细步骤、流程图和实际案例,帮助用户深入理解筛选器的层级关系与综合应用技巧,并提供常见问题解决方案,助力高效精准的数据分析与可视化展示。 阅读详情

相关推荐

AD7920实战:从咪头到ADC的音频信号采集电路设计全解析(附电路图)

本文详细解析了基于AD7920 ADC芯片的音频信号采集电路设计全流程。从驻极体咪头的驱动、AD8542运放的两级增益与偏置设计,到关键的抗混叠滤波器配置,以及ADC接口的驱动缓冲与PCB布局要点,提供了完整的实战指南与电路图,帮助开发者实现高质量音频信号采集。

red88的博客 803

HDU2181 哈密顿绕行世界问题 —— DFS

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2181 哈密顿绕行世界问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5132    Accepted Submi

A man can be destroyed, but not defeated. 416

第四篇:关于python程序打包的问题-找不到fsspec

这个问题困扰了我将近两天的时间一直找不到什么好的办法,甚至打算放弃。主要原因是身边没有可以述说的人,也没有可以请教的人。正在想要放弃的时候找到了解决办法。 打包后运行程序是这样的, 大概意思是找不见fsspec这个依赖,刚接触python说实话对于这些第三方库理解不是很到位,我的理解就是:类似于java程序中的jar包,程序找不见了。可怎么让他找见了,刚开始以为我自己没有安装fsspec,在cmd中进行了安装,结果如下图所示 很明显,已经安装并且安装目录都有,跟着网上的一些解决办法,在打包的时候把这.

weixin_47861710的博客 5865

[dfs]hdu2181 哈密顿绕行世界问题

C - 哈密顿绕行世界问题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u SubmitStatus Description 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 Input 前20行的第i行有3个数,

童凌的技术博客 597

内网Linux服务器离线安装python包

3、将下载的依赖包和requirements.txt 拷贝到内网主机,依赖包和requirements.txt放同一级目录,进入该目录,运行指令。其实还有个更加方便的办法,联网主机装个与内网主机一样环境的虚拟机,在虚拟机中下载py包,拷贝到内网主机后就能直接安装了,省去手动下载py包的步骤。简单记录下最近遇到的一个小问题,内网主机没有内网源,处于无互联网状态,安装python包只能通过联网主机下载好后拷贝到内网主机。由于内网主机安装了多个版本的python,为了防止搞错,使用这种方式来调用pip安装。

cyc头发还挺多的博客 651

瑞芯微RK3576开发板实战:6TOPS NPU如何加速你的AIoT项目(附性能测试)

本文以瑞芯微RK3576开发板为核心,深入探讨其6TOPS NPU在AIoT项目中的实战应用。通过详细的性能测试对比,展示了NPU如何将AI模型推理速度提升15倍以上,并大幅降低CPU负载。文章涵盖从环境搭建、模型转换优化到多屏异显与系统级调优的全流程,为开发者提供了将硬件算力转化为实际项目加速效果的完整指南。

oauth7security的博客 820

HDU 2181 哈密顿绕行世界问题

HDU 2181 哈密顿绕行世界问题 TimeLimit:3000/1000MS(Java/Others)MemoryLimit:32768/32768K(Java/Others) ProblemDescription - 题目描述   一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚...

123

【Unity的HDRP渲染管线下实现好用的GUI模糊和外描边流光效果_Blur_OutLine_案例分享(内附源码)】

因为没有用到纹理,但介于是UI层,没有MainTeX的时候,会提示报错,所以这里加上了MainTex,最后不在片段着色渲染出来既可。这样UI层级显示正常了,但旋转后的模糊效果,跟背景拼接不上,有很大的偏移。猜测是屏幕UV采样错误导致,只要找到屏幕UV数值,更正过来就可以了,RenderTexture设置一下Size既可,其他的先不管。没有贴图,用Shader实现外描边流光效果。将主相机拖入Render Camera。新建一个RenderTexture。

暴走约伯的博客 1149

HDU-2181 哈密顿绕行世界问题(dfs)

Problem Description: 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 Input: 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出. Output: 输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多...

一只在校程序猿的技术贴 323

UFS软件分区介绍

本文主要介绍了ufs软件分区管理的概况,能够使大家对软件分区有个大体的认识

肥匪斐's blogs 1万+

嵌入式工程师成长之路(0)----认识元件

在电子设计与维修中,认识元件是成功的关键!面对琳琅满目的电阻、电容、电感与二极管,样子形式千奇百怪,你是否也曾陷入困难? 本文基于行业权威分类标准,结合十年工程师实战经验,深度解析4大类、30+子类电子元件的核心特性、应用场景与避坑指南,助你从“小白”秒变“电子高手”!

云轩阁 11万+

HDU 2181 哈密顿绕行世界问题(DFS 深度优先搜素)

哈密顿绕行世界问题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。    Input 前

小夏 的博客 457

深度学习工具包 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 2181哈密顿绕行世界问题 dfs

传送门:hdu 2181 中文题就不多说了,唯一值得注意的一点是dfs到最后cnt==20的时候要先判断最后一个城市和第一个城市连不连通再输出。#include #include #include int map[22][22]; int book[22]; int line[22]; int t=0,m; using namespace std; int dfs(int cnt) {

WA是一笔财富 434

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

HDU 2181哈密顿绕行世界问题【dfs】

哈密顿绕行世界问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7364    Accepted Submission(s): 4368   Problem Description 一个规则的实心十二面体,它的 20个顶点标出世...

Emiya丶的博客 258

哈密顿绕行世界问题 HDU - 2181(dfs)

哈密顿绕行世界问题  HDU - 2181 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。  Input 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m&lt;=20,m&gt;=1.m=0退出.  Output 输出从第m个城市出发经过每个城市1次又回到m的所有路线,如...

Learning_is_endless的博客 271

hdu 2181 哈密顿绕行世界问题(dfs)

http://acm.hdu.edu.cn/showproblem.php?pid=2181 哈密顿绕行世界问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2483    Accepted Submission(s): 1

大太阳 444

HDU 2181 哈密顿绕行世界问题(DFS)

哈密顿绕行世界问题             Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)                    Total Submission(s): 698Accepted Submission(s): 423 Problem D...

MengDeMao1234的博客 173

HDU2181 哈密顿绕行世界问题 DFS

HDU2181 哈密顿绕行世界问题 DFS

htrdchh的博客 261

HDU 2181哈密顿绕行世界问题(还是DFS)

哈密顿绕行世界问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2670    Accepted Submission(s): 1673 Problem Description 一个规则的实心十二面体,它的 2

AC_Dreameng 1234

HDU2181 哈密顿绕行世界问题【DFS+暴力】

题目链接:哈密顿绕行世界问题 分析:暴力dfs向后延伸20位,注意判断第20位是否能回到起点; #include<bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; const int maxn=1e5+7; const int mod=1e9+7; const ll INF=...

MaJorieL 180

HDU - 2181 哈密顿绕行世界问题【dfs】

哈密顿绕行世界问题 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8150 Accepted Submission(s): 4784 Problem Description 一个规则的实心十二面体,它的 20个顶点标出世界著名的2...

qq_43966202的博客 215

HDU 2181 哈密顿绕行世界问题(DFS)

题意   由20个顶点的图,输入每个点联通的点,输入出发点后,按字典序输出所有通过所有点回到出发点的路线 思路   将每个顶点联通的点从小到大存储后DFS找出所有路线 代码 /* HDU 2181 dfs */ #include<iostream> #include<vector> #include<algorithm> #include<cstrin...

IuSpet的博客 314

HDU2181 哈密顿绕行世界问题 dfs

哈密顿绕行世界问题 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3209    Accepted Submission(s): 1980 Problem Description 一个规则的实心十二面体,它的 20个顶点

要做ADC 2643

HDU - 2181 哈密顿绕行世界问题 (DFS)

哈密顿绕行世界问题 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 Input 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出. Output 输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,...

YOONGI 143

HDU 2181-哈密顿绕行世界问题(裸dfs)

E - 哈密顿绕行世界问题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2181 Appoint description:  System Crawler  (2015-11-14) Descripti

梧桐下的四叶草 382
上一篇: poj 3414 Pots(bfs)
下一篇: Lua入门教程
accelerator_2016
博客等级 码龄11年 3粉丝 24原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值