| 记录编号 | 196967 | 评测结果 | AAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 2064.爬山 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.003 s | ||
| 提交时间 | 2015-10-22 22:24:10 | 内存使用 | 0.31 MiB | ||
// KZ's
#include <fstream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
ifstream fin ("mountain.in");
ofstream fout ("mountain.out");
int a,b,d;
long long n;
fin>>n>>d>>a>>b;
if (a>b) {
int u=a;
a=b;
b=u;
}
int c=(b-a)%d;
long long t=n-1-(b-a)/d;
if (t&1)
fout<<t/2*d+b;
else
fout<<t/2*d+b-c;
return 0;
}
// UBWH