Codeforces 702 D Road to Post Office
题目描述
Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to ddkilometers.
Vasiliy's car is not new — it breaks after driven every kk kilometers and Vasiliy needs tt seconds to repair it. After repairing his car Vasiliy can drive again (but after kk kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.
To drive one kilometer on car Vasiliy spends aa seconds, to walk one kilometer on foot he needs bb seconds ( a<ba<b ).
Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.
输入输出格式
输入格式:
The first line contains 5 positive integers d,k,a,b,td,k,a,b,t ( 1<=d<=10^{12}1<=d<=1012 ; 1<=k,a,b,t<=10^{6}1<=k,a,b,t<=106 ; a<ba<b ), where:
dd — the distance from home to the post office;
kk — the distance, which car is able to drive before breaking;
aa — the time, which Vasiliy spends to drive 1 kilometer on his car;
bb — the time, which Vasiliy spends to walk 1 kilometer on foot;
- tt — the time, which Vasiliy spends to repair his car.
输出格式:
Print the minimal time after which Vasiliy will be able to reach the post office.
输入输出样例
5 2 1 4 10
14
5 2 1 4 5
13
说明
In the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.
In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.
小学数学题。。。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#define ll long long
using namespace std;
ll cost,d,b,a,k,t,n;
int main(){
scanf("%lld%lld%lld%lld%lld",&d,&k,&a,&b,&t);
ll xl=(a-b)*k+t,tim=d/k+(d%k?:);
cost=min(b*d,d*a+(tim-)*t); if(k<=d){
if(xl>) cost=min(cost,b*d-t+xl);
else{
n=d/k;
cost=min(cost,xl*n+b*d-t);
}
} printf("%lld\n",cost);
return ;
}
Codeforces 702 D Road to Post Office的更多相关文章
- Educational Codeforces Round 15 Road to Post Office
Road to Post Office 题意: 一个人要从0走到d,可以坐车走k米,之后车就会坏,你可以修或不修,修要花t时间,坐车单位距离花费a时间,走路单位距离花费b时间,问到d的最短时间. 题解 ...
- 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 702D D. Road to Post Office(数学)
题目链接: D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input ...
- D. Road to Post Office 解析(思維)
Codeforce 702 D. Road to Post Office 解析(思維) 今天我們來看看CF702D 題目連結 題目 略,請直接看原題. 前言 原本想說會不會也是要列式子解或者二分搜,沒 ...
- 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 ...
- cf702D Road to Post Office
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces 702D Road to Post Office(模拟 + 公式推导)
题目链接:http://codeforces.com/problemset/problem/702/D 题意: 一个人要去邮局取东西,从家到达邮局的距离为 d, 它可以选择步行或者开车,车每走 k 公 ...
- CodeForces 702D Road to Post Office
答案的来源不外乎于3种情况: 纯粹走路,用时记为${t_1}$:纯粹乘车,用时记为${t_2}$:乘车一定距离,然后走路,用时记为${t_3}$. 但是${t_1}$显然不可能成为最优解. 前两个时间 ...
随机推荐
- noip 2011观光公交
P1315 观光公交 95通过 244提交 题目提供者该用户不存在 标签贪心递推2011NOIp提高组 难度提高+/省选- 提交该题 讨论 题解 记录 题目描述 风景迷人的小城Y 市,拥有n 个美 ...
- idea初学建立maven项目报错
原理,是因为你没把新创建好的maven项目给设置成一个可被tomcat部署的web项目 参考此博文,讲的非常详细: 归根到底是因为web项目的部署问题: 解决方案:在创建的到时候,idea下部会提示是 ...
- 开发中常遇到的Python陷阱和注意点
最近使用Python的过程中遇到了一些坑,例如用datetime.datetime.now()这个可变对象作为函数的默认参数,模块循环依赖等等. 在此记录一下,方便以后查询和补充. 避免可变对象作为默 ...
- AWS文档与用户指南
AWS Command Line Interface http://docs.amazonaws.cn/cli/latest/userguide/cli-chap-welcome.html VM Im ...
- 关于ora-12154:TNS:could not resolve the connect identifier specified
一:前言 刚刚出来实习,在公司配的电脑里面装的oracle和PL SQL时一次性就搞定,但是在自己的电脑上装了就出现这个问题,刚刚在网上看了下,所以自己就写份记载吧! 二: 在打开PLSQL Deve ...
- MySQL实现分页查询
imit 基本实现方式 一般情况下,客户端通过传递 pageNo(页码).pageSize(每页条数)两个参数去分页查询数据库中的数据,在数据量较小(元组百/千级)时使用 MySQL自带的 limit ...
- 【Foreign】异色弧 [树状数组]
异色弧 Time Limit: 20 Sec Memory Limit: 256 MB Description Input Output 仅一行一个整数表示答案. Sample Input 8 1 ...
- 金中欢乐赛 C题
题目传送门 这道题 hash就可以写了 弄了半天有点智障 强行压一压就okay了的说 #include<cstdio> #include<cstring> #include&l ...
- Java任务调度框架----kunka
初衷 工作中用到了很多框架,但是给我印象最深的还是我们PO(Product Owner)在若干年前写的一套任务调度框架,在JDK1.4之前,concurrent包还没有引入, 手写的这套Token调度 ...
- Git-回滚操作
git revert是用一次新的commit来回滚之前的commit,git reset是直接删除指定的commit git log 查询回滚版本唯一commit标识代码 git reset --ha ...