http://codeforces.com/contest/702

题意:人到邮局去,距离d,汽车在出故障前能跑k,汽车1公里耗时a,人每公里耗时b,修理汽车时间t,问到达终点最短时间

思路:计算车和人的平均速度,谁快用谁,最后特判<=k的距离

 // #pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define pi acos(-1.0)
const int N = 1e5+;
const int MOD = 1e9+;
#define inf 0x7fffffff
typedef long long LL; void frein(){freopen("in.txt","r",stdin);}
void freout(){freopen("out.txt","w",stdout);}
inline int read(){int x=,f=;char ch=getchar();while(ch>''||ch<'') {if(ch=='-') f=-;ch=getchar();}while(ch>=''&&ch<='') { x=x*+ch-'';ch=getchar();}return x*f;} int a[N];
int b[N]; int main(){
LL d,k,a,b,t;
cin>>d>>k>>a>>b>>t;
if((d-d%k)<=){
printf("%I64d\n",a*d);
exit();
}
LL ans1,ans2;
if((double)(1.0*(k*a+t)/k)<b){
ans1=(d-d%k)*a+(d/k-)*t;
d-=d/k*k;
ans2=min(a*d+t,b*d);
}
else {
ans1=(d-k)*b;
ans2=k*min(a,b);
}
printf("%I64d\n",ans1+ans2);
return ;
}

codeforce 702D Road to Post Office 物理计算路程题的更多相关文章

  1. CodeForces 702D Road to Post Office

    答案的来源不外乎于3种情况: 纯粹走路,用时记为${t_1}$:纯粹乘车,用时记为${t_2}$:乘车一定距离,然后走路,用时记为${t_3}$. 但是${t_1}$显然不可能成为最优解. 前两个时间 ...

  2. Codeforces 702D Road to Post Office(模拟 + 公式推导)

    题目链接:http://codeforces.com/problemset/problem/702/D 题意: 一个人要去邮局取东西,从家到达邮局的距离为 d, 它可以选择步行或者开车,车每走 k 公 ...

  3. codeforces 702D D. Road to Post Office(数学)

    题目链接: D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input ...

  4. D. Road to Post Office 解析(思維)

    Codeforce 702 D. Road to Post Office 解析(思維) 今天我們來看看CF702D 題目連結 題目 略,請直接看原題. 前言 原本想說會不會也是要列式子解或者二分搜,沒 ...

  5. Educational Codeforces Round 15 Road to Post Office

    Road to Post Office 题意: 一个人要从0走到d,可以坐车走k米,之后车就会坏,你可以修或不修,修要花t时间,坐车单位距离花费a时间,走路单位距离花费b时间,问到d的最短时间. 题解 ...

  6. Codeforces Educational Codeforces Round 15 D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  7. cf702D Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. Educational Codeforces Round 15_D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. Educational Codeforces Round 15 D. Road to Post Office 数学

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

随机推荐

  1. Java学习笔记之:Java封装

    一.引言 在面向对象程式设计方法中,封装(英语:Encapsulation)是指,一种将抽象性函式接口的实作细节部份包装.隐藏起来的方法. 封装可以被认为是一个保护屏障,防止该类的代码和数据被外部类定 ...

  2. linux系统启动级别

    linux运行级别 以管理员身份进入Linux,修改文件:/etc/inittab 找到"id:5:initdefault:"其中的5就是X-window,为默认的运行级别 lin ...

  3. Tomcat启动后访问首页报错 显示JSP 空指针异常

    HTTP Status 500 - type Exception report message description The server encountered an internal error ...

  4. NSDate & NSDateFormatter

    #import <Foundation/Foundation.h>   int main(int argc, const char * argv[]) {    @autoreleasep ...

  5. OpenRisc-52-run openrisc&orpmon on ml501 board

    引言 之前关于openrisc的内容,几乎都是基于opencores官方的ordb2a那个开发板的,但是,实际情况是有那个板子的人不是很多,所以目前我在做一个与之类似的板子,并且很快就会跟大家见面,这 ...

  6. Android开发之LocationManager和定位

    代码: /* * 获取当前的位置,并通过短信发送位置到指定号码 */ public class LocationService extends Service { private LocationMa ...

  7. AWS Python SDK boto3中的基本概念与使用方法

    最近在用boto3编写AWS的lamda函数,学习到了boto3中的一些基本概念与使用方法.在此进行总结. 1. boto3提供了两个级别的接口来访问AWS服务:High Level的Resource ...

  8. 新浪实时股票数据接口http://hq.sinajs.cn/list=code

    股票数据的获取目前有如下两种方法可以获取:1. http/javascript接口取数据2. web-service接口 1.http/javascript接口取数据1.1Sina股票数据接口以大秦铁 ...

  9. "xxxx".zip:这个压缩文件格式未知或者数据已经被损坏,打不开压缩文件,总出现这个提示的解决方法

    从网上下载了一些压缩文件,有时解压时会出现“这个压缩文件格式未知或者数据已经被损坏”或“未找到压缩文件”的提示. 造成的原因有两种: 一.网站上的压缩文件本来就是坏的. 1.你可以尝试可以使用WINR ...

  10. 搜集的一些RTMP项目,有Server端也有Client端

    查询一些RTMP的协议封装时找到了一些RTMP开源项目,在这里列举一下,以后有时间或是有兴趣可以参考一下: just very few of them. Red5 only contains a se ...