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 ...
随机推荐
- Apahce的虚拟用户认证及server-status页
一.Apache虚拟用户认证配置 编辑配置文件加入如下内容: <Directory "/www/htdoc/fin"> Options None AllowOverri ...
- Codeforces Round #104 (Div. 1)
A.Lucky Conversion 题意 给定两个长度为 \(N(N \le 10^5)\) 且由4和7构成的 \(a, b\)串 对 \(a\) 可以有两种操作: 交换两个位置的字符; 改变一个位 ...
- JAVA基本语义简介
1.标识符 标识符可以有字母.数字.下划线(_).美元符($)组成,但不能包含@.%.空格等其他特殊符,不能以数字开头. 标识符不能是JAVA关键字和保留字(JAVA预留的关键字,以后的升级版中有可能 ...
- HDU-1011 Starship Troopers (树形DP+分组背包)
题目大意:给一棵有根带点权树,并且给出容量.求在不超过容量下的最大权值.前提是选完父节点才能选子节点. 题目分析:树上的分组背包. ps:特判m为0时的情况. 代码如下: # include<i ...
- 【P1304】【P1305】选课与选课输出方案
多叉树归 原题: 学校实行学分制.每门的必修课都有固定的学分,同时还必须获得相应的选修课程学分.学校开设了N(N<500)门的选修课程,每个学生可选课程的数量M是给定的.学生选修了这M门课并考核 ...
- lua 初接触 --- The first time use Lua for programing
The first time use Lua for programing Wang Xiao 1. 关于 lua 的变量类型: lua 变量的定义与matlab有点不同: local d , f ...
- python--flask使用
Flask是一个使用 Python 编写的轻量级 Web 应用框架.下面我将使用Flask框架,创建一个简单的html页面示例. 1.项目的目录结构如下所示:exweb\ uniqueenv\ a ...
- CSS实例:鼠标滑过超级链接文字时改变背景颜色
先讲简单的: 通过CSS可以设置超链接在不同时刻的颜色: <style> a:link {color: #FF0000} /* 未访问的链接 */ a:visited {color: #0 ...
- MySQL分库分表环境下全局ID生成方案 转
在大型互联网应用中,随着用户数的增加,为了提高应用的性能,我们经常需要对数据库进行分库分表操作.在单表时代,我们可以完全依赖于数据库的自增ID来唯一标识一个用户或数据对象.但是当我们对数据库进行了分库 ...
- VLOOKUP 函数
如果需要在表格或区域中按行查找内容,可使用 VLOOKUP,它是一个查找和引用函数.例如,按部件号查找汽车部件的价格. =VLOOKUP(要查找的值.要在其中查找值的区域.区域中包含返回值的列号.精确 ...