sdut 2154:Shopping(第一届山东省省赛原题,水题)
Shopping
Time Limit: 1000MS Memory limit: 65536K
题目描述
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 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.
输出
示例输入
4
24 13 89 37
6
7 30 41 14 39 42
0
示例输出
152
70
提示
来源
水题,最大值减最小值的差乘以二就是结果。
代码:
#include <iostream>
#include <stdio.h>
using namespace std; int main()
{
int n;
int a[];
while(scanf("%d",&n)!=EOF){
if(n==) break;
long long Max=,Min=;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
if(a[i]>Max) //找到最大值
Max = a[i];
if(a[i]<Min) //找到最小值
Min = a[i];
}
long long sum =(Max-Min)*;
cout<<sum<<endl;
} return ;
}
Freecode : www.cnblogs.com/yym2013
sdut 2154:Shopping(第一届山东省省赛原题,水题)的更多相关文章
- sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)
Ivan comes again! Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...
- sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)
Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...
- sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)
Clockwise Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...
- sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)
Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...
- sdut 2163:Identifiers(第二届山东省省赛原题,水题)
Identifiers Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Identifier is an important c ...
- sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)
The Android University ACM Team Selection Contest Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里 ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- 第一届山东省ACM——Phone Number(java)
Description We know that if a phone number A is another phone number B’s prefix, B is not able to be ...
- 第一届山东省ACM——Balloons(java)
Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...
随机推荐
- SqlServer字段说明查询及快速查看表结构
SqlServer字段说明查询 SELECT t.[name] AS 表名,c.[name] AS 字段名,cast(ep.[value] )) AS [字段说明] FROM sys.tables A ...
- 关于SQLite在Android开发中的知识点总结
一.存放位置 1.内部存储-放在 data/data 底下, 也就是内部存储, 里面的文件以及文件夹是私有的, 其他 app 不能访问, 也随着 app 卸载而删除; 2.放在 sd 卡里面, 如果设 ...
- ajax 缓存问题及解决方案
ajax 缓存问题及解决方案 CreationTime--2018年7月25日16点04分 Author:Marydon 1.什么情况下ajax请求会出现缓存? 当请求的路径.参数名.参数值三者都 ...
- IDEA中同窗口导入新的maven项目
创建请看这个:http://www.cnblogs.com/oskyhg/p/6649266.html 下边开始导入: 完毕. 结果展示:
- 【windows7】解决IIS 80端口占用问题(亲测)
1.默认你win机器已经安装并启用了80端口 2.现在你要安装并启用apache服务器 3.首先进行80端口占用检测:netstat -aon|findstr 80 4.找到进程号为404的服务名称, ...
- 强制关机后导致VBOX(4.2.16 r86992)的虚拟机不可使用问题的解决MEMO
上周六晚上由于有急事,就强制关机,导致今天晚上用VirtualBox(4.2.16 r86992)时,虚拟机上写着不可使用. 显示异常Message如下: D:\tinderbox\win-4.2\s ...
- Ubuntu桌面操作快捷键
Ubuntu操作基本快捷键 * 打开主菜单 = Alt + F1 * 运行 = Alt + F2 * 打开终端 = Alt+F2 然后输入gnome-terminal回车 * 显示桌面 = Ctrl ...
- IO多路复用之epoll
1.基本知识 epoll是在2.6内核中提出的,是之前的select和poll的增强版本.相对于select和poll来说,epoll更加灵活,没有描述符限制.epoll使用一个文件描述符管理多个描述 ...
- REST开放接口生成文档工具之apidoc
一.安装node.js环境 感谢阿里云,下载的链接http://npm.taobao.org/mirrors/node/latest-v6.x/ 二.安装apidoc npm install apid ...
- ItelliJ项目打jar包
不是Eclipse里方便的export...了. 一.配置 . 点击View->Open Module Settings(快捷键是F4) . 在弹出的对话框中,点击最左侧树的Artifacts ...