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 ...
随机推荐
- 对于delphi for linux心存梦想的同学,彻底醒醒吧
Borland 曾经多次做市场调查,很多人呼吁推出delphi for linux.可是直到kylix发展到第三版,borland才明白:一个内置C编译器环境并与之关系紧密的免费OS,没有人愿意花钱去 ...
- Maven中心仓库
当你使用Maven构建一个项目,Maven会检查你的pom.xml文件,找出需要下载的依赖包.首先它会到本地仓库查找所需的文件,如果没找到,就到默认的中心仓库(这是新的http://search.ma ...
- apache prefork和worker模式的比较
http://www.t086.com/article/4443 http://www.cnblogs.com/fnng/archive/2012/11/20/2779977.html
- math模块及使用方式
在数学之中,除了加减乘除四则运算之外——这是小学数学——还有其它更多的运算,比如乘方.开方.对数运算等等,要实现这些运算,需要用到 Python 中的一个模块:Math 模块(module)是 Pyt ...
- [Codeforces667A]Pouring Rain(数学,几何)
题目链接:http://codeforces.com/contest/667/problem/A 题意:一个杯子里有水,一个人在喝并且同时在往里倒.问这个人能不能喝完,多久能喝完. 把相关变量都量化成 ...
- hdu 3501 Calculation 2 (欧拉函数)
题目 题意:求小于n并且 和n不互质的数的总和. 思路:求小于n并且与n互质的数的和为:n*phi[n]/2 . 若a和n互质,n-a必定也和n互质(a<n).也就是说num必定为偶数.其中互质 ...
- EXT 数据按F12,F11 显示问题
最近做关于EXT的项目,因为是刚开始接触EXT,对什么都不熟悉,所以把其他人写好的浏览页代码考过了来,换成自己需要的. 一切都做好了,然后数据不出来,就调试看,后台也出现数据了,然后就按F12调试前台 ...
- BootStrap基本样式
文本对齐风格:.text-left:左对齐.text-center:居中对齐.text-right:右对齐.text-justify:两端对齐 取消列表符号:.list-unstyled内联列表:.l ...
- bzoj1109
我们设f[i]为保留第i个木块最多的符合未知数 显然f[i]=max(f[j])+1 满足i>j a[i]>a[j] i-j>=a[i]-a[j] 我们把最后一个式子变成a[i]-i ...
- poj1088
这题是dp还是dfs+记忆化?(其实好像没什么区别?) 用f[i,j]表示滑到(i,j)时之后最多能滑多远,依次穷举每一个起点(i,j)则 f[i,j]=max{f[i,j-1],f[i-1,j],f ...