Educational Codeforces Round 15 Road to Post Office
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 15 (A - E)
比赛链接:http://codeforces.com/contest/702 A. Maximum Increase A题求连续最长上升自序列. [暴力题] for一遍,前后比较就行了. #inclu ...
- Educational Codeforces Round 15 D 数学推公式
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 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 ...
- 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 ...
- Educational Codeforces Round 15 C. Cellular Network(二分)
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 C 二分
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- MySQL二进制日志的备份和恢复
二进制日志:记录数据库修改的相关操作,作用是即时点回复,主从复制 可以按时间滚动,也可以按大小滚动 server-id:服务器身份标识 一.二进制文件的删除方法,千万不要手动删除 PURGE BINA ...
- spark 分析sql内容再插入到sql表中
package cn.spark.study.core.mycode_dataFrame; import java.sql.DriverManager;import java.util.ArrayLi ...
- poj2367 拓扑序
题意:有一些人他们关系非常复杂,一个人可能有很多后代,现在要制定一种顺序,按照前辈在后代前排列就行 拓扑序裸题,直接建边拓扑排序一下就行了. #include<stdio.h> #incl ...
- lightoj1074 最短路
题意:有n个城市,每个城市有拥挤值,有一些单向道路,从某个城市到另一个城市的花费是拥挤值差的三次方,当然可能是负的值.问从1点到某点最少的花费,若小于3或不能到达输出“?” 建图的边权是拥挤值差的三次 ...
- fasterflect-vs-hyperdescriptor-vs-fastmember-vs-reflection/
http://www.codewrecks.com/blog/index.php/2008/10/04/expression-tree-vs-reflection/ http://www.codepr ...
- Unity模型导入导出
从3DMAX导出,参考: http://tieba.baidu.com/p/2807225555 -> 使用3dmax 2013,会自带导出 fbx 的功能 -> 从 3dmax 导出 - ...
- 递归遍历多维数组(树数据结构)的超级简单方式,并且可以递归超过200层,摘自<<PHP精粹:编写高效PHP代码>>
<?php $array = array( "Hello", // Level 1 array( "World" // Level 2 ), array( ...
- ejs使用
ejs使用 从npm上下载最新的ejs刚写了个例子 先pull出来,网上太多例子都不好用,googlecode上的代码根本下不下来,只能去翻npm安装下来的文件里的说明文件,模仿着写出来一个 var ...
- shell之echo与printf和颜色
在用户的bashrc中添加一行export来修改提示符.
- 安装max plugin wizard
参考:http://liweizhaolili.blog.163.com/blog/static/162307442013117731953/