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 ...
随机推荐
- 发布WebService 1.1
webservice1.1是基于jdk发布的 package cn.itcast.service01; import javax.jws.WebService; import javax.xml.ws ...
- EMQ ---客户端上线自动订阅主题
通过修改配置文件即可实现. emq v2.3.11,软件架构做了调整,把功能集成在了emq_modules模块,/data/loaded_plugins默认会加载emq_modules. 我们只需要改 ...
- 对log4cpp进一步封装
//Mylog.h如下: #pragma once//#include <iostream>#include <log4cpp/Category.hh>#include < ...
- bcdedit
我的电脑装了双系统:Win2003 SP2(C盘)和Win2008 SP2(D盘),最近2003一启动就蓝屏unknown hard error,安全模式也进不去,恢复注册表等方法试过也不行,但200 ...
- Altera Quartus II下载中途失败
1.Altera 的quartus II 下载程序时中途失败,有可能是程序写的不对(缺少初始状态,else补全等等) 2.下载程序pof最好也用英文命名,再下载.
- C# FTP操作类可用
public class FtpClient { #region 构造函数 /// <summary> /// 创建FTP工具 /// <para> /// 默认不使用SSL, ...
- (oneway void) release中oneway的意思
oneway is used with the distributed objects API, which allows use of objective-c objects between dif ...
- Struts2使用OGNL遍历各种map总结
一.Action中的代码:MapAction.java package com.zx.demo.action; import java.util.ArrayList; import java.ut ...
- bazel-编译多目标
demo2 使用bazel编译多目标示例,一个bianry,一个library. demo2目录树 ── demo2 ├── app │ ├── BUILD │ ├── func.cpp ...
- 【高并发简单解决方案】redis缓存队列+mysql 批量入库+php离线整合
原文出处: 崔小拽 需求背景:有个调用统计日志存储和统计需求,要求存储到mysql中:存储数据高峰能达到日均千万,瓶颈在于直接入库并发太高,可能会把mysql干垮. 问题分析 思考:应用网站架构的衍化 ...