ZOJ_1037_Gridland

人体检测技术之TOF 智能人脸/视频锁领域的人体检测需求是要求远距离达到1m左右即可,一旦在此距离内检测人,则锁唤醒进行人脸识别,视频录制等操作。所以,人体检测技术非常关键。选型主要是几个维度:1.支持检测的距离范围,能否准确输出距离信息2.支持检测FOV3.场景适应性如何,如人体衣服颜色4.环境适应性如何,夏天高温环境下的测距是否准确5.批量一致性情况。 阅读详情
Gridland

Time Limit: 2 Seconds       Memory Limit: 65536 KB

Background

For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of them efficient algorithms are already available, these are the "easy" problems like sorting, evaluating a polynomial or finding the shortest path in a graph. For the "hard" ones only exponential-time algorithms are known. The traveling-salesman problem belongs to this latter group. Given a set of N towns and roads between these towns, the problem is to compute the shortest path allowing a salesman to visit each of the towns once and only once and return to the starting point.


Problem

The president of Gridland has hired you to design a program that calculates the length of the shortest traveling-salesman tour for the towns in the country. In Gridland, there is one town at each of the points of a rectangular grid. Roads run from every town in the directions North, Northwest, West, Southwest, South, Southeast, East, and Northeast, provided that there is a neighbouring town in that direction. The distance between neighbouring towns in directions North-South or East-West is 1 unit. The length of the roads is measured by the Euclidean distance. For example, Figure 7 shows 2 * 3-Gridland, i.e., a rectangular grid of dimensions 2 by 3. In 2 * 3-Gridland, the shortest tour has length 6.

 
Figure 7: A traveling-salesman tour in 2 * 3-Gridland.

Input

The first line contains the number of scenarios.

For each scenario, the grid dimensions m and n will be given as two integer numbers in a single line, separated by a single blank, satisfying 1 < m < 50 and 1 < n < 50.


Output

The output for each scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. In the next line, print the length of the shortest traveling-salesman tour rounded to two decimal digits. The output for every scenario ends with a blank line.


Sample Input

2
2 2
2 3


Sample Output

Scenario #1:
4.00

Scenario #2:
6.00 



题意:看图基本能明白意思了,就是经过所有的结点要产生回路,所有结点只经过一次。

思路:直接画图举几个例子很容易找到规律,m,n相乘为偶数答案就是m*n,如果为奇数,最后则需要走斜线答案就是,m*(n-1)+1.41(就是根号2)


Sample Program Here

#include<iostream>
#include<iomanip>  //控制格式的头文件
using namespace std;
///////////偶数就是m*n,奇数答案就是m*n+0.41注意最后转化成double输出 还有最后也是有空行的
int main(){

  int i=1,m,n,num;
  cout<<fixed<<setprecision(2);
  cin>>num;
  for(i=1;i<=num;i++){
	  cin>>m>>n;
	  if( (m*n)%2==0 ){
	     cout<<"Scenario #"<<i<<":"<<endl;
		 cout<<(double)m*n<<endl;
	  }
	  else{
	     cout<<"Scenario #"<<i<<":"<<endl;
		 cout<<m*n+0.41<<endl;	  
	  }
	  cout<<endl;
  }

  return 0;
}



操作系统|知识梳理|复习(下) 操作系统复习 阅读详情

相关推荐

利用SPSS实现逻辑回归,树模型,以及广义线性模型

本案例是IBM SPSS数据分析与挖掘实战案例精粹----第九章的学习记录 案例背景:分析出导致急救后迟发性颅脑损伤的主要影响因素,共有201项案例: 分析思路:先使用logistic回归模型进行影响因素筛选,然后利用分类树探索自变量中是否存在交互作用,最后利用广义线性模型过程拟合带交互项的Logistic回归模型 字段:性别,年龄,收缩压,舒张压,血小板,脑挫伤,中线位移,脑肿胀,入院意识,是否手术急救,其余急救措施,是否出现迟发性脑损伤; ...

hepan_defeng的博客 1万+

zoj 1037

Gridland Background For years, computer scientists have been trying to find efficient solutions to different computing problems. For s

1017

kivy--入门(一)(Windows)python

从零开始学习kivy 由于课程需要写一个app,还要写报告,这就很愁人,头秃,脑壳大。 虽然学过Android,但是小编对于Java就像对牛弹琴似的,不能说完全不懂,只能说Java这个语言不太适合我,不学还不行,还是先利用python的kivy编写一个吧。 在各大网站搜索开发app,发现适合写手机app的除了Android还有kivy,所以还是先学习如何使用吧! 文章目录从零开始学习kivy前言一、安装二、添加按钮+标签三、文本输入(TextInput)总结 前言 首先推荐这篇博客kivy的安装和使用

刘念卿的博客 9968

Security Onboard Communication-SecOC

一、通讯加密的必要性 随着汽车电子的发展及整车功能复杂性的提高,车载控制器数量从之前的寥寥几个增加至规模复杂的上百个。基于功能的需求,各个控制器每时每刻需要进行大量数据的交互,数据交互的方式也多种多样,比如Lin、CAN、CANFD、FlexRay 、车载Ethernet等。 其中成本低、可靠性高、应用普遍的有Lin、CAN通讯,而FlexRay、车载Ethernet等基于成本因素,目前主...

toywang123的博客 4189

华为防火墙USG6600全流量日志配置指南:从流量监控到NAT日志的完整方案

本文详细介绍了华为USG6600防火墙全流量日志配置方案,涵盖流量监控、NAT日志及安全事件溯源等核心功能。通过精细化配置和性能优化技巧,帮助企业构建高效、合规的日志体系,提升网络安全运维效率。文章特别强调了日志采样与字段过滤的实用方法,适用于高流量环境下的资源优化。

gin88的博客 347

新建菜单Office被替换为腾讯文档 - 解决方案

右键新建菜单中的Office被替换为腾讯文档。原因是安装了腾讯文档软件,此软件安装时会自动将新建菜单中的Office替换为腾讯文档,下文介绍解决方案。

NSJim的博客 2928

杭电acm1046 Gridland

杭电acm1046                                             Gridland Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2113    Accepted Submission(s

怪凯的专栏 1436

条件DDPM:Diffusion model的第三个巅峰之作

前言:DDPM从2020年诞生,短短一年的时间,模型上有两个巨大的改进,其中一个就是condition的引入,最近大部分DDPM相关的论文都会讨论这一点,有些文章称之为latent variable。和当年GAN的发展类似,CGAN和DCGAN的出现极大程度上促进了GAN的发扬光大,意义重大。本文基于前面几篇文章继续聊一聊: 从VAE到Diffusion Model_沉迷单车的追风少年-优快云博客 为什么diffusion model扩散模型可以称为score-based models?_沉迷单车的.

沉迷单车的追风少年 1万+

1.21 英语翻译打卡

链接:Gridland | JXNUOJ 描述: For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of them efficient algorithms are already available, these are the “easy” problems like sorting, evaluating a po

m0_63365528的博客 345

1985-2021年30m全国逐年土地覆被数据(含分省数据)

基于CLCD,揭示了1985年至2019年期间中国土地覆被变化的趋势和模式,如不透水表面(+148.71%)和水(+18.39%)的扩大,耕地(-4.85%)和草地(-3.29%)的减少,以及森林(+4.34%)的增加。由于中国的一系列造林政策,如1980年代启动的三北防护林工程和2000年后启动的绿色增益工程,从1985年到 2019年,森林增加了4.34%,灌木减少了259万公顷,与 ESACCI_LC的减少趋势相似。尽管为了养活不断增长的人口,中国东北和西北地区进行了广泛的开垦,但耕地普遍减少。

J_Giser的博客 1469

【WRF-Chem教程第四期上】运行 WRF-Chem 模型

完整介绍运行 WRF-Chem 模型的详细步骤

WW、forever的博客 3108

2021-09-30每日刷题打卡

一、ZOJ-1037:Gridland 1.1 问题描述 Background For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of them efficient algorithms are already available, these are the “easy” problems like sorting, ev

soulandlove的博客 438

【LLM技术全景】规模定律与模型演进:为什么模型越大越强?

规模定律性能 ∝ 参数量^N性能 ∝ 数据量^M性能 ∝ 计算量^L其中 N, M, L 是小于1的正数(通常0.05~0.15)关键观察损失与规模的关系呈幂律(不是线性,也不是对数)三个要素(参数、数据、计算)需要协调增长只增加其中一个要素,收益会边际递减规模定律(Scaling Law):1. 模型性能与参数量、数据量、计算量呈幂律关系2. Kaplan定律(2020):参数量是主要因素3. Chinchilla定律(2022):数据和参数同等重要,最优比例1:20。

专注:太空算力、AI infra、异构调度、大模型成本工程 495

ZOJ 1037 Gridland

HOJ 1037 Gridland问题 很简单的数学问题,大家一画图就知道,当m和n有一个为偶数时,刚好可以走完一圈,这就是最短路径,当m和n都为奇数时,走的过程中必须要走一个斜边,所以要在上一中情况下加上根号2. #include&lt;stdio.h&gt; int main() { int caseNumber,i; int N,M; scanf("%d",&am...

上帝是笨蛋的博客 308

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

ZOJ P1037 HDOJ P1046 Gridland

Gridland Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2384    Accepted Submission(s): 1139 Problem Description For years, comput

kdwycz的刷题空间 883

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

ZOJ Problem Set - 1037 Gridland

ZOJ Problem Set - 1037 Gridland Time Limit: 2 Seconds                                     Memory Limit: 65536 KB                             Background   For years, computer scientists

Jackwuyongxing的专栏 669

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

zoj 1037 Gridland

Gridland Time Limit: 2 Seconds      Memory Limit: 65536 KB Background For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of

学学学,敲敲敲 381

ZOJ Problem Set - 1037 Gridland

Gridland Time Limit: 2 Seconds      Memory Limit: 65536 KB Background For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of

acm_1361677193的专栏 405

ZOJ 1037 - Gridland(格子世界)

GridlandTime Limit:2 Seconds Memory Limit:65536 KB BackgroundFor years, computer scientists have been trying to find efficient solutions to different computing problems. For some of them ...

aiyu520704的博客 254

ZOJ1037-Gridland

#include int main() { int t; double m ,n; scanf("%d", &t); for (int i = 1; i <= t; i++) { scanf("%lf%lf", &m, &n); printf("Scenario #%d:\n", i); if ((int

Collider 638

zoj 1037 Gridland

题目描述:给出一个n*m的格点,每一个代表有一个城市,从一个城市到达另一个城市可以通过东、西、南、北、东南、东北、西南、西北。问:寻找一条最短的路,访问每个城市一次有且只有一次,又回到出发点,求最短路径长度 问题分析:当n或者m为偶数的时候,最短路长度为nm 当n和m同时为奇数的时候,最短路长度为nm+0.41 转载于:https://www....

weixin_30436891的博客 159

zoj 1037 gridland

//这一题比较简单,主要是想得明白其中的走法就容易解决了!分两种情况! #include "iostream" #include "cmath" using namespace std; const double a = sqrt(double (2)); int main() { int TestCase, casecount = 0; cin >> TestCase

yzl_rex 904
上一篇: ZOJ_1001_A + B Problem
下一篇: ZOJ_1048_Financial Management
wankaiming
博客等级 码龄15年 49粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值