ZOJ_1037_Gridland

Windows MCP 安装教程:让 AI 代理与 Windows 系统无缝交互 通过以上步骤,你已经成功安装和配置了 Windows MCP 服务。现在你的 Cursor 编辑器可以通过 MCP 协议与 Windows 系统进行深度交互,AI 代理能够:启动和控制应用程序执行系统命令自动化 UI 操作获取系统状态信息这为 AI 辅助开发和工作流程自动化提供了强大的基础。如果你在使用过程中遇到任何问题,欢迎在评论区讨论或查看项目的官方文档。 阅读详情
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;
}



若依框架二次开发——RuoYi-AI 本地部署流程 阅读详情

相关推荐

封装CTP API为Java SDK

本文介绍了在Windows环境下使用Java调用CTP API的编译实现过程。首先需要准备CTP API SDK、JDK、SWIG和Visual Studio等工具,配置好开发环境。然后通过搭建目录结构、编写SWIG接口文件ctp.i,实现C++到Java的代码转换。文中详细说明了文件目录组织方式,并提供了处理中文乱码的代码示例。通过这一系列步骤,最终将CTP的C++接口转换为Java可调用的形式,为Java项目获取期货实时报价数据提供支持。

weixin_43952815的博客 1222

zoj 1037

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

1017

Sentaurus TCAD学习——Scheme编程语言

sentaurus scheme语言学习记录

摸摸小熊猫的博客 964

Security Onboard Communication-SecOC

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

toywang123的博客 4189

施耐德 Modicon M580 ePAC 项目实战:从硬件选型到 Control Expert V15 组态

本文详细解析了施耐德 Modicon M580 ePAC 在工业自动化项目中的实战应用,从硬件选型到 Control Expert V15 组态的全流程。重点介绍了水处理站控制系统的硬件配置、网络架构设计、软件安装授权及程序框架开发,帮助工程师高效实施中大型控制系统项目。

weixin_33701617的博客 326

ubuntu22.04 安装部署 openclaw

ubuntu22.04 安装部署 openclaw

nalanxiaoxiao2011的博客 973

杭电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

四旋翼黑科技揭秘:如何利用PX4隐藏的角加速度数据提升控制性能

本文深入探讨了如何利用PX4飞控中隐藏的角加速度数据,结合增量非线性动态逆(INDI)控制方法,显著提升四旋翼无人机的控制性能。通过实战教程,指导开发者从数据订阅、INDI原理到代码实现,构建响应更快、鲁棒性更强的控制回路,有效应对突风与快速机动。

lake5的博客 719

ZOJ1037解答

Apple Wang 1491

通达信源码-金牛暴起

趋势1:=3*SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1)-2*SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1) AND SJTJ,DOTLINE,COLORGRAY;谷:=(((DD-LLV(DD,21))/(HHV(DD,21)-LLV(DD,21)))*(4))*(25);{0,25指高度};

qq_57222058的博客 3520

2025年上半年第1批信息系统项目管理师论文真题解析与范文

文章首先分析了项目经理在交付绩效域中应关注的重点领域,然后按照项目管理五大过程组顺序,阐述了各过程组中与交付绩效域协同的绩效域及协调目标,最后制定了各过程组中交付绩效域的测量指标。本项目的实践表明,系统化的交付绩效管理不仅能保证项目成功,还能创造超出预期的业务价值。需要结合具体项目案例,按照五大过程组(启动、规划、执行、监控、收尾)顺序,分析各过程组中与交付绩效域协同的其他绩效域及其协调目标。价值交付连续性:建立敏捷交付机制,将项目分解为12个迭代周期,每周期交付可验证成果,确保价值持续流动。

Programming Talk 820

ZOJ Problem Set - 1037

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 efficie

daguge1的专栏 417

Codex 赋能UI自动化测试

✅ 零编码门槛:业务人员也能直接上手✅ 无需复杂配置:跳过部署陷阱,分钟级启用✅ 无权限风险:沙箱隔离 + 操作审计,安全可控✅ 精准匹配 UI 自动化需求:生成代码与执行操作一体化本文我使用CRM系统分类管理功能进行测试演示,手把手教你从测试用例编写,到上传Codex、自动执行浏览器操作,每一步都有细节,看完直接复刻到工作中。

十二测试录 458

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

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

假人有限元模型

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

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

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

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

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

WINCC7.3破解文件

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

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、付费专栏及课程。

余额充值