hdu 1008】的更多相关文章

题意: 电梯当前在0层,每在1层需要停5秒,往上走每层需6秒,往下走每层需要4秒. 思路: 在接收输入的时候直接计算了它,不用再弄一个循环.每计算一个请求就更新当前层,停留5秒的等到输出时再加上5*n就行了.这样老实计算就不需要考虑特殊情况了,比如第一个请求是在0层,是不是得停5秒先? #include <iostream> using namespace std; void main() { ,ans=,s=,i,a; while(scanf("%d",&n)&a…
#include<iostream> using namespace std; int main() { int n; ]; while(cin>>n) { ,m=; ) break; ;i<n;i++) { cin>>a[i]; if(a[i]>m) { t+=(a[i]-m)*; } else if(a[i]<m) { t+=(m-a[i])*; } m=a[i]; t=t+; // 因为同层时要停留 所以t+=5不能放到if里面去 } cout&…
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will s…
题目意思是:给你N个数字  每个数字表示多少层楼  现在要你从0层楼开始坐电梯  一次按顺序走过这些楼层 规则是 上楼6秒 ,下楼4秒,每次到达一个楼层停5秒..... 思路:模拟 代码如下:(要注意的是 如果电梯没动 也就是temp==0,这也是一种情况.....被坑了..) #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { ]; w…
Elevator其实是一道水题,思路也很简单,但不知道怎么也不能AC,后来看了别人的再比较自己的以后找到错误. 在判断奇偶数之后的语句时,我用了if()  else if(),这是不能AC的原因,这种条件判断的话,会忽略连续输入两个相等数的情况. #include <iostream> using namespace std; int e[105]; int main() { int n; while(cin>>n&&n!=0) { int time_0 = 0;…
Problem Description A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.   Output Output the approximations of e generated by the ab…
HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsum  贪心 HDU 1004 Let the Balloon Rise  字典树,map HDU 1005 Number Sequence  求数列循环节 HDU 1007 Quoit Design  最近点对 HDU 1008 Elevator  模拟 HDU 1010 Tempter of th…
Rabbit Kingdom Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 40    Accepted Submission(s): 20 Problem Description Long long ago, there was an ancient rabbit kingdom in the forest. Every rabbit…
Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 505    Accepted Submission(s): 260 Problem Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny…
MU Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 134    Accepted Submission(s): 71 Problem Description Suppose there are the symbols M, I, and U which can be combined to produce strings…