浙江大学PAT_甲级_1046. Shortest Distance (20)

ARTIX-7 GTP 3G-SDI 工程构建与调试实战 本文详细介绍了基于ARTIX-7 FPGA和GTP收发器的3G-SDI工程构建与调试实战。从基础概念解析到Vivado工程创建、GTP IP核配置、SDI IP核集成,再到系统集成与时钟域处理,提供了全面的技术指导。文章还分享了调试技巧、常见问题排查方法以及性能验证步骤,帮助开发者快速掌握3G-SDI视频传输技术的实现与优化。 阅读详情

题目链接:点击打开链接

The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.

Input Specification:

Each input file contains one test case. For each case, the first line contains an integer N (in [3, 105]), followed by N integer distances D1 D2 ... DN, where Di is the distance between the i-th and the (i+1)-st exits, and DN is between the N-th and the 1st exits. All the numbers in a line are separated by a space. The second line gives a positive integer M (<=104), with M lines follow, each contains a pair of exit numbers, provided that the exits are numbered from 1 to N. It is guaranteed that the total round trip distance is no more than 107.

Output Specification:

For each test case, print your results in M lines, each contains the shortest distance between the corresponding given pair of exits.

Sample Input:
5 1 2 4 14 9
3
1 3
2 5
4 1
Sample Output:
3
10
7
我的C++程序:

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n,m;//n个点,m对两点距离
	int temp,min_distance=0,cycle_length=0;//min_distance两点最短距离,cycle_length圈长度
	int a, b;//起点a,终点b
	int i = 0;
	int distance[100000];//istance[i]存储第i个点到第一个点的距离,i>=1
	cin >> n;
	for (i = 1;i <= n;i++)
	{
		cin >> temp;
		cycle_length += temp;//计算圆圈长度
		distance[i + 1] = distance[i] + temp;
	}
	cin >> m;
	while (m--)
	{
		cin >> a >> b;
		min_distance = abs(distance[b] - distance[a]);
		cout << min(min_distance, cycle_length- min_distance)<< endl;//圆圈内的两点最短距离
	}
	//system("pause");
	return 0;
}


不止于HTTPS请求:用VS2022编译的libcurl玩转文件上传和代理设置 本文详细介绍了如何使用VS2022编译的libcurl库实现文件上传和高级代理配置。通过实战代码示例,展示了多部分表单上传、二进制数据上传以及各种代理设置技巧,帮助C++开发者提升网络编程能力。 阅读详情

相关推荐

基因树构建全流程:从OrthoFinder到iTOL的保姆级教程(附兰科植物案例)

本文提供了一份从OrthoFinder到iTOL的基因树构建全流程保姆级教程。详细解析了利用OrthoFinder构建物种树、IQ-TREE构建无根基因树、Notung进行树调和生根,以及最终在iTOL中实现专业可视化的每一步操作与实战经验,并以兰科植物NB-ARC基因家族为例进行演示,帮助研究者系统掌握基因树分析方法。

tequila的博客 534

【PAT甲级A1046】Shortest Distance (20分)(c++)

1046 Shortest Distance (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits. Input Specific

小庄同学的博客 181

wsl + vscode 离线配置 ERROR: Faild to download https://update.code.visualstudio.com

很多情况下是没有现成的VS Code Server程序的,需要手动下载。记住上面的Commit ID,可以通过下面的链接下载 vscode-server-linux-x64.tar.gz。然后将vscode-server-linux-x64.tar.gz上传在服务器上的$HOME/.vscode-server/bin文件夹中,解压。在wsl中下载不了 vscode 的核心。运行下面两行命令,建立空的$HOME/.vscode-server/bin文件夹。重新运行 wsl与vs的链接即可。

点云算法工程师 3804

浙江大学PAT_甲级_1094. The Largest Generation (25)

题目链接:点击打开链接 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest po

~~(v_v)~~ 1240

活用QueryWrapper与@Select注解,构建MybatisPlus动态多表查询方案

本文深入探讨了如何结合MybatisPlus的QueryWrapper与@Select注解,构建高效灵活的动态多表关联查询方案。通过解析${ew.customSqlSegment}占位符机制,并设计通用的Service层封装,解决了复杂条件下多表查询的SQL拼接难题,显著提升了后台管理系统列表查询的开发效率与可维护性。

weixin_29291069的博客 280

AUTOSAR RTE配置实战:从ECU分区到Task映射的完整指南

本文提供了一份AUTOSAR RTE配置的完整实战指南。从创建ECU分区、定义OS任务,到实现Runnable Entity与Task的精确映射,详细解析了每一步的操作要点与常见陷阱。文章结合配置工具界面,旨在帮助开发者高效完成RTE配置,确保系统实时性与数据一致性,是掌握AUTOSAR核心开发流程的实用参考。

weixin_29228203的博客 492

PAT_甲级_1001. A+B Format (20)

1001. A+B Format (20)   Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input...

~~(v_v)~~ 1172

中兴通讯招聘测评答题技巧,真题解析(附真题)

中兴招聘测评、中兴入职测评、中兴线上考试

guang221315221的博客 5829

浙江大学PAT_甲级_1005.1005. Spell It Right (20)

c++实现

~~(v_v)~~ 991

从零构建物联网监控系统:STM32+迪文屏+WiFi模组的实战解析

本文详细解析了基于STM32微控制器、迪文串口屏和WiFi模组构建物联网监控系统的完整方案。从硬件选型、系统架构设计到数据交互实现,提供了包括迪文屏GUI开发、STM32通信协议、低功耗优化等实战经验,帮助开发者快速掌握物联网监控系统的核心技术。

docker7nomad的博客 743

【论文翻译】Enhancing Channel Estimation in High Mobility OTFS Systems: A Novel Pilot-Based Method...

本文介绍了一种用于正交时频空间(OTFS)调制系统的新型基于导频的信道估计方法。我们提出的方法是在ZP-OTFS系统的零填充区域插入一行导频符号,具有减少开销和降低峰均功率比(PAPR)的显著优势。特别是,通过沿多普勒轴分布导频符号,我们的方法在高移动性场景下依然能够提供鲁棒且精确的信道估计,这是像TransPod这种时速超过1000 km/h的运输系统的一个典型特征。这一点至关重要,因为在此类场景下,多普勒频移可能会导致系统性能的严重退化。

Cuby的博客 1223

浙江大学PAT_甲级_1032. Sharing (25)

题目地址:点击打开链接 To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suf

~~(v_v)~~ 778

【蓝凌表单】JSP组件常用语法整理

【代码】【蓝凌表单】JSP组件常用语法整理。

烧硬盘 723

PAT_甲级_1029. Median (25)

题目链接:点击打开链接   Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16...

~~(v_v)~~ 746

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

浙江大学PAT_甲级_1035. Password (20)

C++

~~(v_v)~~ 736

数学建模模型总结

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

浙江大学PAT_甲级_1081. Rational Sum (20)

题目链接:点击打开链接 Given N rational numbers in the form "numerator/denominator", you are supposed to calculate their sum. Input Specification: Each input file contains one test case. Each case sta

~~(v_v)~~ 730

浙江大学PAT_甲级_1023. Have Fun with Numbers (20)

python

~~(v_v)~~ 721

浙江大学PAT_甲级_1036. Boys vs Girls (25)

C++

~~(v_v)~~ 715

PAT_甲级_1065. A+B and C (64bit) (20)

题目链接:点击打开链接   Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B &gt; C. Input Specification: The first line of the input gives the positive number of test cases,...

~~(v_v)~~ 706

浙江大学PAT_甲级_1070. Mooncake (25)

题目链接:点击打开链接 Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the regio

~~(v_v)~~ 687

浙江大学PAT_甲级_1028. List Sorting (25)

C++

~~(v_v)~~ 678

浙江大学PAT_甲级_1019. General Palindromic Number (20)

C++ stack vector

~~(v_v)~~ 652

浙江大学PAT_甲级_1058. A+B in Hogwarts (20)

python2,C++

~~(v_v)~~ 644

浙江大学PAT_甲级_1041. Be Unique (20)

C++ map

~~(v_v)~~ 639

数据结构分类与基本类型:线性、非线性、连续与分散

从 vector 与 list 的内存差异切入,讲清逻辑结构、物理结构,以及基本数据类型与数据结构的区别。

凡人叶枫的博客 357

数据结构( Floyd)

核心公式:dist[i][j] = min( dist[i][j], dist[i][k] + dist[k][j] )2 首先 先用第一个顶点“v0”作为中转站 尝试去缩短dist二维数组中保存的各个顶点之间的最短路径。3 然后 再用第二个顶点“v1”作为中转站 尝试去缩短dist二维数组中保存的各个顶点之间的最短路径。4 最后 用最后一个顶点“v2”作为中转站 尝试去缩短dist二维数组中保存的各个顶点之间的最短路径。思路 逐个把每一个等待当作“中转站”去尝试缩短其余各个顶点之间的最短路径。

2503_92775091的博客 238

计算机考研 408 数据结构 散列表 平均查找长度 ASL

拉链法将冲突元素形成链表,开放定址法则将冲突元素放入其他位置。查找成功平均查找长度(ASL成功)为各序列查找次数之和除以序列个数;查找失败ASL失败为每种哈希值失败次数之和除以哈希值个数。删除元素后需重新计算ASL。装填因子影响性能,初始散列地址相同易引发聚集或堆积,导致查找效率下降。

查理的博客 239
上一篇: 浙江大学PAT_甲级_1041. Be Unique (20)
下一篇: 浙江大学PAT_甲级_1050. String Subtraction (20)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址