Road to Post Office

题意:

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

题解:

首先要分成k段,k段的总长是ovmod,每一段可以选择修车坐车或选择走路,(只有第一段的时候不用修车),最后在加上剩下的那些路的时间,剩下的是mod,(可以选择修车坐车或选择走路)最后min答案就好了。但其中还有一种情况要注意,就是前ovmod也可以选择坐车之后不修走着,所以这种要特殊处理下。

代码:

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
#define PU puts("");
#define PI(A) cout<<A<<endl
#define SI(N) cin>>N
#define SII(N,M) cin>>N>>M
#define cle(a,val) memset(a,(val),sizeof(a))
#define rep(i,b) for(int i=0;i<(b);i++)
#define Rep(i,a,b) for(int i=(a);i<=(b);i++)
#define reRep(i,a,b) for(int i=(a);i>=(b);i--)
#define dbg(x) cout <<#x<<" = "<<x<<endl
#define PIar(a,n) rep(i,n)cout<<a[i]<<" ";cout<<endl;
#define PIarr(a,n,m) rep(aa,n){rep(bb, m)cout<<a[aa][bb]<<" ";cout<<endl;}
const double EPS= 1e-9 ; /* ///////////////////////// C o d i n g S p a c e ///////////////////////// */ const int MAXN= 1000 + 9 ; ll d,k,a,b,t; int main()
{
iostream::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
while(cin>>d>>k>>a>>b>>t)
{
ll ans=0;
if (d<=k)
{
cout<<min(d*a,d*b)<<endl;
continue;
}
ll mod=d%k;
ll ovmod=d/k*k;
//后面的那种情况就是,选择坐车之后不修走着
ans+=min(min(ovmod/k*t-t+ovmod*a,ovmod*b),(ovmod-k)*b+k*a);
ans+=min(t+mod*a,mod*b);
PI(ans);
}
return 0;
}

Educational Codeforces Round 15 Road to Post Office的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Educational Codeforces Round 15 (A - E)

    比赛链接:http://codeforces.com/contest/702 A. Maximum Increase A题求连续最长上升自序列. [暴力题] for一遍,前后比较就行了. #inclu ...

  5. Educational Codeforces Round 15 D 数学推公式

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

  6. Codeforces Educational Codeforces Round 15 C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Educational Codeforces Round 15 A. Maximum Increase

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  9. Educational Codeforces Round 15 C 二分

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. apache开启url rewrite模块

    在把服务器数据转移到本地服务器之后,本地打开首页出现排版紊乱等问题,经过大神指点说是url rewrite的问题. 本篇文章主要写怎样开启apache的url rewrite功能. 打开Apache2 ...

  2. POJ-3107 Godfather

    题目大意:给一棵无根树,找出所有满足下面的条件的点:删除它后,最大子树中的个数最少. 题目分析:两次深搜,第一次找出子树中节点的个数,第二次维护最大子树. ps:边用vector保存时会超时... 代 ...

  3. 点亮LED(库函数实现)

    本次测试采用的芯片是STM32F103CB 我的开发板如下: 此开发板有8个led,分别为D11,D12,D13,D14,D15,D16,D17,D18.查询核心板的电路图后知道其对应芯片的控制引脚为 ...

  4. soap的简单实现(PHP)

    1.非wsdl模式 (1)函数文件 testphp/ServiceFunctions.class.php <?php /** * @author 左小兵 * */ class ServiceFu ...

  5. 在windows系统上安装caffe

    下载编译 0.确认电脑上有VS2013 0.确认显卡GPU Compute Capability>=3.0 1.安装CUDA7.5 2.下载cuDNN v4,添加到CUDA7.5 3.根据htt ...

  6. Andorid面试问题整理

    Acitivty的四中启动模式与特点. standard:默认的启动模式 singleTop:适合那种接受通知启动的页面,比如新闻客户端之类的,可能会给你推送好几次 ,但是每次都是打开同一张页面调用o ...

  7. linux知识点

    通过gui来使用通过api来使用通过cli来使用通过tui来使用 进程不在,但tcp连接还一直存在的解决办法--tcpkill命令 http://www.centoscn.com/CentOS/Int ...

  8. 生成n个数的全排列【递归、回溯】

    下面讨论的是n个互不相同的数形成的不同排列的个数.毕竟,假如n个数当中有相同的数,那n!种排列当中肯定会有一些排列是重复的,这样就是一个不一样的问题了. /*===================== ...

  9. Swagger-UI 基于REST的API测试/文档类插件

    现在多数的项目开发中,网站和移动端都需要进行数据交互和对接,这少不了使用REST编写API接口这种场景.例如我目前的工作,移动端交由了另一团队开发,不同开发小组之间就需要以规范和文档作为标准和协作基础 ...

  10. ExtJs学习笔记之Window组件

    Window窗体组件 window是一个指定的打算作为一个应用程序窗口的面板,默认窗口是浮动的,resizable, 并且draggable,默认的,窗体靠document.body呈现. 1.示例: ...