Shopping
题目描述
Saya and Kudo go shopping together.
You can assume the street as a straight line, while the shops are some points on the line.
They park their car at the leftmost shop, visit all the shops from left to right, and go back to their car.
The input consists of several test cases.
The first line of input in each test case contains one integer N (0<N<100001), represents the number of shops.
题目描述
Saya and Kudo go shopping together.
You can assume the street as a straight line, while the shops are some points on the line.
They park their car at the leftmost shop, visit all the shops from left to right, and go back to their car.
Your task is to calculate the length of their route.
The input consists of several test cases.
The first line of input in each test case contains one integer N (0<N<100001), represents the number of shops.
The next line contains N integers, describing the situation of the shops. You can assume that the situations of the shops are non-negative integer and smaller than 2^30.
The last case is followed by a line containing one zero.
For each test case, print the length of their shoppi

该博客介绍了2010年山东省第一届ACM大学生程序设计竞赛中的一道题目Shopping,任务是计算购物路线的长度。题目描述了商店的位置情况,并指出每个测试案例的商店位置是非负整数且小于2^30。样例解释了一个从最左侧到最右侧再返回的购物路径计算,强调了解题关键在于正确计算(最大值-最小值)*2,并提及设置最小值的重要性。
最低0.47元/天 解锁文章
190

被折叠的 条评论
为什么被折叠?



