当前位置:网站首页>Pat 1046 shortest distance (20 points) simulation
Pat 1046 shortest distance (20 points) simulation
2022-07-06 02:39:00 【Python ml】
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n,m,sum=0,start,end;
cin>>n;
vector<int>a(n),dis(n+1);
for(int i=1;i<n;i++){
scanf("%d",&a[i]);
dis[i+1]=dis[i]+a[i]; //dis[i] From the starting point to the i The distance between nodes
sum+=a[i];
}
scanf("%d",&a[0]);
sum+=a[0]; //sum Is the sum of the circular journey
cin>>m;
for(int i=0;i<m;i++){
cin>>start>>end;
if(start>end) swap(start,end);
int temp=dis[end]-dis[start];
cout<<min(temp,sum-temp)<<endl;
}
return 0;
}
边栏推荐
- Redis cluster deployment based on redis5
- Keyword static
- Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
- Introduction to robotframework (II) app startup of appui automation
- Large scale DDoS attacks take Myanmar offline
- [Wu Enda machine learning] week5 programming assignment EX4 - neural network learning
- Dachang image library
- 零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
- 爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
- 2345文件粉碎,文件强力删除工具无捆绑纯净提取版
猜你喜欢

解决:AttributeError: ‘str‘ object has no attribute ‘decode‘

"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.5 automatic differentiation_ Learning thinking and exercise answers

【MySQL 15】Could not increase number of max_ open_ files to more than 10000 (request: 65535)

HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22](/img/e0/21367eeaeca10c0a2f2aab3a4fa1fb.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24](/img/2e/b1f348ee6abaef24b439944acf36d8.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12](/img/b1/926d9b3d7ce9c5104f3e81974eef07.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9](/img/ed/0edff23fbd3880bc6c9dabd31755ac.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9

2345文件粉碎,文件强力删除工具无捆绑纯净提取版

QT release exe software and modify exe application icon
随机推荐
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
Y a - t - il des cas où sqlcdc surveille plusieurs tables et les associe à une autre? Tout fonctionne dans MySQL
Six stone management: why should leaders ignore product quality
A copy can also produce flowers
球面透镜与柱面透镜
Paper notes: graph neural network gat
Zero basic self-study STM32 wildfire review of GPIO use absolute address to operate GPIO
Easy to use js script
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
Pat grade a 1033 to fill or not to fill
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
Ue4- how to make a simple TPS role (II) - realize the basic movement of the role
【MySQL 15】Could not increase number of max_open_files to more than 10000 (request: 65535)
Maturity of master data management (MDM)
Solution: attributeerror: 'STR' object has no attribute 'decode‘
Introduction to robotframework (I) brief introduction and use
技术管理进阶——什么是管理者之体力、脑力、心力
HDU_p1237_简单计算器_stack
构建库函数的雏形——参照野火的手册
MySQL winter vacation self-study 2022 11 (8)