比赛 |
20151019 |
评测结果 |
AAAAAAWWWW |
题目名称 |
爬山 |
最终得分 |
60 |
用户昵称 |
dashgua |
运行时间 |
0.002 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2015-10-19 21:26:56 |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
template<class Num>void read(Num &x)
{
char c; int flag = 1;
while((c = getchar()) < '0' || c > '9')
if(c == '-') flag *= -1;
x = c - '0';
while((c = getchar()) >= '0' && c <= '9')
x = (x<<3) + (x<<1) + (c-'0');
x *= flag;
}
template<class Num>void write(Num x)
{
if(!x) {putchar('0');return;}
if(x < 0) putchar('-'), x = -x;
static char s[20];int sl = 0;
while(x) s[sl++] = x%10 + '0',x /= 10;
while(sl) putchar(s[--sl]);
}
const double eps = 1e-6;
int n, d, a, b;
int main()
{
double x;
freopen("mountain.in","r",stdin);
freopen("mountain.out","w",stdout);
read(n), read(d), read(a), read(b);
x = ((double)(b - a) / d + (n + 1)) / 2;
write(std::max(d * ((int)(floor(x) + eps) - 1) + a, d * (n - (int)(ceil(x) + eps)) + b));
fclose(stdin);
fclose(stdout);
return 0;
}