作业帮 > 综合 > 作业

杭电1008水题,怎么会wa了?顺便菜鸟师傅.

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/05/15 12:14:19
杭电1008水题,怎么会wa了?顺便菜鸟师傅.
#include
#include
using namespace std;
int main(int argc,char *argv[])
{int n,s,p,m,i;
while(cin>>n&&n!=0)
{
p=0,s=0;
for(i=0;i>m;
if(pm)
{s+=(p-m)*4+5;
p=m;}
}
cout
杭电1008水题,怎么会wa了?顺便菜鸟师傅.
//
#include
#include
using namespace std;
int main(int argc,char *argv[])
{
int n,s,p,m,i;
while(cin >> n && n != 0)
{
p = 0,s = 0;
for(i = 0; i < n; i++)
{
cin >> m;
if(p < m)
{
s += (m - p) * 6 + 5;
p = m;
}
//if(p > m) //还有一种情况就是:还在考虑到哪一层,在原地暂停 5S
else //所以改用else 即可
{
s += (p - m) * 4 + 5;
p = m;
}
}
cout