PAT (Advanced Level) 1008 Elevator (20 分)
程序员文章站
2022-07-15 13:26:07
...
题目描述:
模拟,计算电梯运行总时间
分析:
逐个比较相邻的楼层,进行大小差值比较后计算时间
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int pre = 0, now;
int sum = 0;
while(cin >> now)
{
if(now > pre) sum += 6 * (now - pre);
else sum += 4 * (pre - now);
sum += 5;
pre = now;
}
cout << sum << endl;
return 0;
}
总结:
注意审题!注意第一个3是总数目,而不是楼层数!
上一篇: 1005 Spell It Right (20 分)——13行代码Ac
下一篇: PAT (Advanced Level) 1009 Product of Polynomials (25 分)
推荐阅读
-
PAT (Basic Level) Practice (中文)1009 说反话 (20 分)
-
PAT (Basic Level) Practice 1009 说反话 (20 分)
-
PAT (Advanced Level) 1015 Reversible Primes (20 分)
-
PAT (Advanced Level) 1012 The Best Rank (25 分)
-
PAT (Advanced Level) Practice - 1122 Hamiltonian Cycle(25 分)
-
PAT (Advanced Level) 1008 Elevator (20 分)
-
PAT (Advanced Level) 1009 Product of Polynomials (25 分)
-
PAT (Advanced Level) 1011 World Cup Betting (20 分)
-
PAT (Advanced Level) 1006 Sign In and Sign Out (25 分)
-
PAT (Advanced Level) 1073 Scientific Notation(20 分)科学计数法