记录编号 |
196155 |
评测结果 |
AAAAAAAAAA |
题目名称 |
爬山 |
最终得分 |
100 |
用户昵称 |
pangxinying |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.003 s |
提交时间 |
2015-10-20 21:35:57 |
内存使用 |
0.31 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;
long long n,d,a,b;
long long x,h;
void dfs(int x,int y);
int main()
{
freopen("mountain.in","r",stdin);
freopen("mountain.out","w",stdout);
cin>>n>>d>>a>>b;
if (a>b)
{
int t=a; a=b; b=t;
}
x=(b-a)/d;
n-=x+1;
if (n%2!=0 || n%2==0 && (b-a)%d==0)
{
h=b+n/2*d;
}
else
{
h=b+(n-1)/2*d+(d-(b-a)%d);
}
cout<<h<<endl;
return 0;
}