题目意思是:给你N个数字  每个数字表示多少层楼  现在要你从0层楼开始坐电梯  一次按顺序走过这些楼层

      规则是 上楼6秒 ,下楼4秒,每次到达一个楼层停5秒.....

思路:模拟

代码如下:(要注意的是 如果电梯没动 也就是temp==0,这也是一种情况.....被坑了..)

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
int n,floor[];
while(scanf("%d",&n)&&n)
{
memset(floor,,sizeof(floor));
int temp,ans=;
for(int i=; i<=n; i++)
{
scanf("%d",&floor[i]);
temp=floor[i]-floor[i-];
if(temp>)
{
ans+=*temp+;
}
if(temp<)
{
ans+=-*temp+;
}
if(temp==)
ans+=;
}
printf("%d\n",ans);
}
}

hdu 1008的更多相关文章

  1. HDU 1008 电梯( 水题)

    题意: 电梯当前在0层,每在1层需要停5秒,往上走每层需6秒,往下走每层需要4秒. 思路: 在接收输入的时候直接计算了它,不用再弄一个循环.每计算一个请求就更新当前层,停留5秒的等到输出时再加上5*n ...

  2. hdu 1008 注意同层情况

    #include<iostream> using namespace std; int main() { int n; ]; while(cin>>n) { ,m=; ) br ...

  3. hdu 1008 Elevator

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description The hig ...

  4. ACM hdu 1008 Elavator

    Elevator其实是一道水题,思路也很简单,但不知道怎么也不能AC,后来看了别人的再比较自己的以后找到错误. 在判断奇偶数之后的语句时,我用了if()  else if(),这是不能AC的原因,这种 ...

  5. HDU 1008 u Calculate e

    Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. Thi ...

  6. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  7. HDU 4777 Rabbit Kingdom (2013杭州赛区1008题,预处理,树状数组)

    Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  8. HDU 4745 Two Rabbits (2013杭州网络赛1008,最长回文子串)

    Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  9. HDU 4662 MU Puzzle (2013多校6 1008 水题)

    MU Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

随机推荐

  1. C# OpenFileDialog

    OpenFileDialog 用于浏览并打开文件,在Windows Forms中使用,表现为标准的Windows对话框. 实例: 1.新建Windows Form Application 2.添加Op ...

  2. react与jQuery对比,有空的时候再翻译一下

    参考资料:http://reactfordesigners.com/labs/reactjs-introduction-for-people-who-know-just-enough-jquery-t ...

  3. 软件测试—— junit 单元测试

    Tasks: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma with Eclipse Write a java pro ...

  4. [翻译]你真的知道你看到的UTF-8字符是什么吗?

    翻译自http://www.pixelstech.net/article/1397877200-You-know-what-UTF-8-is-when-you-see-it- Source : son ...

  5. 下载编译和测试Android 源代码

    http://source.android.com/source/downloading.html 其中出现错误 repo: fatal: error unknown url type: https ...

  6. VBS创建数据库

    '创建数据库'参数:strDBPath 字符串型 数据库文件的完整路径Sub CreateDataBase(strDBPath)Dim catObjSet catObj = CreateObject( ...

  7. js 获取当前日期时间 格式为 yyyy-mm-dd hh:MM:ss

    ------------------------------------------------------------------------------------ js 获取当前日期时间 格式为 ...

  8. LINE最新版6.5.0在iOS上的删除信息取证

    iOS: 9.3.2版 LINE: 6.5.0版 取出LINE的数据库 Line.sqlite,路径如下所示: 检视删除的信息,发现还有不少残留,虽然都是片段,但拼拼凑凑总还是能有些蛛丝马迹,毕竟,总 ...

  9. Linux下yum安装MPlayer 或 LVC视频播放器

    添加第三方源 su -c 'rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noar ...

  10. leetcode 14

    14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array ...