博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces 702 D Road to Post Office
阅读量:5291 次
发布时间:2019-06-14

本文共 2345 字,大约阅读时间需要 7 分钟。

题目描述

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.

 

输入输出样例

输入样例#1: 
5 2 1 4 10
输出样例#1: 
14
输入样例#2: 
5 2 1 4 5
输出样例#2: 
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
#include
#include
#include
#include
#include
#include
#define ll long longusing 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?1:0); cost=min(b*d,d*a+(tim-1)*t); if(k<=d){ if(xl>0) cost=min(cost,b*d-t+xl); else{ n=d/k; cost=min(cost,xl*n+b*d-t); } } printf("%lld\n",cost); return 0;}

 

转载于:https://www.cnblogs.com/JYYHH/p/8393386.html

你可能感兴趣的文章
20130330java基础学习笔记-语句_for循环嵌套练习2
查看>>
Spring面试题
查看>>
窥视SP2010--第一章节--SP2010开发者路线图
查看>>
MVC,MVP 和 MVVM 的图示,区别
查看>>
C语言栈的实现
查看>>
代码为什么需要重构
查看>>
TC SRM 593 DIV1 250
查看>>
SRM 628 DIV2
查看>>
2018-2019-2 20165314『网络对抗技术』Exp5:MSF基础应用
查看>>
统计单词,字符,和行
查看>>
《Akka应用模式:分布式应用程序设计实践指南》读书笔记8
查看>>
jQuery垂直滑动切换焦点图
查看>>
Python-S9-Day127-Scrapy爬虫框架2
查看>>
模运算
查看>>
python多线程的使用
查看>>
团队编程项目作业1-成员简介及分工
查看>>
使用Chrome(PC)调试移动设备上的网页
查看>>
UI基础--手写代码实现汤姆猫动画
查看>>
使用gitbash来链接mysql
查看>>
黑盒测试和百合测试的优缺点对比
查看>>