codeforce 702D Road to Post Office 物理计算路程题
http://codeforces.com/contest/702
题意:人到邮局去,距离d,汽车在出故障前能跑k,汽车1公里耗时a,人每公里耗时b,修理汽车时间t,问到达终点最短时间
思路:计算车和人的平均速度,谁快用谁,最后特判<=k的距离
// #pragma comment(linker, "/STACK:102c000000,102c000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
// #include <conio.h>
using namespace std;
#define pi acos(-1.0)
const int N = 1e5+;
const int MOD = 1e9+;
#define inf 0x7fffffff
typedef long long LL; void frein(){freopen("in.txt","r",stdin);}
void freout(){freopen("out.txt","w",stdout);}
inline int read(){int x=,f=;char ch=getchar();while(ch>''||ch<'') {if(ch=='-') f=-;ch=getchar();}while(ch>=''&&ch<='') { x=x*+ch-'';ch=getchar();}return x*f;} int a[N];
int b[N]; int main(){
LL d,k,a,b,t;
cin>>d>>k>>a>>b>>t;
if((d-d%k)<=){
printf("%I64d\n",a*d);
exit();
}
LL ans1,ans2;
if((double)(1.0*(k*a+t)/k)<b){
ans1=(d-d%k)*a+(d/k-)*t;
d-=d/k*k;
ans2=min(a*d+t,b*d);
}
else {
ans1=(d-k)*b;
ans2=k*min(a,b);
}
printf("%I64d\n",ans1+ans2);
return ;
}
codeforce 702D Road to Post Office 物理计算路程题的更多相关文章
- CodeForces 702D Road to Post Office
答案的来源不外乎于3种情况: 纯粹走路,用时记为${t_1}$:纯粹乘车,用时记为${t_2}$:乘车一定距离,然后走路,用时记为${t_3}$. 但是${t_1}$显然不可能成为最优解. 前两个时间 ...
- Codeforces 702D Road to Post Office(模拟 + 公式推导)
题目链接:http://codeforces.com/problemset/problem/702/D 题意: 一个人要去邮局取东西,从家到达邮局的距离为 d, 它可以选择步行或者开车,车每走 k 公 ...
- 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 題目連結 題目 略,請直接看原題. 前言 原本想說會不會也是要列式子解或者二分搜,沒 ...
- Educational Codeforces Round 15 Road to Post Office
Road to Post Office 题意: 一个人要从0走到d,可以坐车走k米,之后车就会坏,你可以修或不修,修要花t时间,坐车单位距离花费a时间,走路单位距离花费b时间,问到d的最短时间. 题解 ...
- 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 ...
- cf702D 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 D. Road to Post Office 数学
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- [cocoapods] 如何卸载工程里的cocoapods
1. 打开自己的工程所在文件夹 删除这4个文件 2. 打开工程,把红线的东西都删除掉 3. 只留下原来的4个,其余都删除掉
- svn:...target\classes\META-INF\MANIFEST.MF (系统找不到指定的路径。)
在上传项目到svn时,pom.xml报错
- Java API —— HashMap类 & LinkedHashMap类
1.HashMap类 1)HashMap类概述 键是哈希表结构,可以保证键的唯一性 2)HashMap案例 HashMap<String,String> ...
- Eclipse groovy in action
Eclipse :Version: Juno Service Release 2GrEclipse plugins:http://dist.springsource.org/release/GRECL ...
- Maven是如何工作的
Maven的依赖机制能够自动下载依赖文件,并且自动维护.更新版本. 让我们通过一个案例来了解Maven是如何工作的,假如你的系统想用log4j作为日志输出工具,让我们看一下传统做法和Maven做法: ...
- 车牌识别LPR(八)-- 字符识别
第八篇:字符识别 车牌定位.车牌倾斜校正.车牌字符分割都是为车牌字符识别做的前提工作,这些前提工作直接关系到车牌识别系统的性能.车牌字符识别是车牌识别系统的核心部分,车牌字符识别的准确率是衡量车牌识 ...
- System,Integer,Calendar,Random和容器
System 1)arraycopy int[] a = {1.2.3.4}; int[] b = new int[5]; System.arraycopy(a,1,b,3,2); //把数组a中从下 ...
- mac 下php运行bug
如下所说bug在window下没有,在mac下存在. mac下的php报如下错误: fopen("data.json") Error: failed to open stream: ...
- nodejs抓网易NBA数据
var http = require("http");var cheerio = require("cheerio"); var url = "htt ...
- Asp.Net连接Mysql报错Out of sync with server
Asp.Net连接Mysql报错Out of sync with server 原因:程序引用的MySql.Data.dll版本高于服务器版本 解决:下载一个低版本的MySql.Data.dll,项目 ...