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 ...
随机推荐
- window.open()的所有参数列表
http://www.cnblogs.com/meil/archive/2006/07/28/462459.html[1.最基本的弹出窗口代码] 其实代码非常简单: <SCRIPT LANGUA ...
- MySQL学习总结(二)数据库以及表的基本操作
上一节中详细的介绍了关于MySQL数据库的安装过程,接下来我们就该对数据库以及表进行一些基本的操作了. 1.数据类型 MySQL数据库中提供了整数类型.浮点数类型.定点数类型.日期和时间类型.字符串类 ...
- C#:消息框
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- 函数适配器bind2nd 、mem_fun_ref 源码分析、函数适配器应用举例
一.适配器 三种类型的适配器: 容器适配器:用来扩展7种基本容器,利用基本容器扩展形成了栈.队列和优先级队列 迭代器适配器:(反向迭代器.插入迭代器.IO流迭代器) 函数适配器:函数适配器能够将仿函数 ...
- 一名全栈工程师Node.js之路-转
Node.js 全球现状 虽然 Node.js 在国内没有盛行,但据 StackOverflow 2016 年开发者调查,其中 node.js .全栈.JavaScript 相关的技术在多个领域(包括 ...
- freeswitch 把SIP注册信息数据库从SQLITE 改为MYSQL的方法
实际线上应用中,在线注册人数超过4000 ,SQLITE就吃不消了,容易造成锁表,考虑转入MYSQL,查了下官网 超过转入了MYSQL. https://wiki.freeswitch.org/wik ...
- asp.net mvc部署iis常见问题
1.Q:iis比网上的少很多选项 A:iis没装全,去控制面板里把没勾选的选项勾选 2.Q:发布mvc遇到的HTTP错误 403.14-Forbidden解决办法 A:需要在web.config里添加 ...
- android studio 使用问题记录
android studio 使用问题记录 下载地址:FQ或园子内好心人提供的国内地址: http://www.cnblogs.com/bjzhanghao/archive/2012/11/14/an ...
- 终端运行apk
启动一个活动 am start -n com.example.apptest/com.example.apptest.MainActivity 替换apk . udisk1/runRCApk.sh s ...
- pentestbox使用教程
pentestbox工具列表:https://tools.pentestbox.org/ freebuf入门实战:http://www.freebuf.com/sectool/125881.html ...