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