UVa 11935 - Through the Desert
来源:互联网 发布:软件著作权 受理登记 编辑:程序博客网 时间:2024/04/30 17:30
题目:你有一辆车,有一串车的运动序列,问车最少的油箱是多大,才能完成这个指令序列。
Fuel consumption n:n/100 km 耗油
Leak:漏洞增加一个,每个洞 1/1 km 耗油
Gas station:加满油
Mechanic:修好所有的漏洞
Goal:到达目标
分析:模拟。最开始考虑从后向前计算,回来想想,不用那么麻烦。
直接设置初始量是0,每次装满就是0,求出路径上的最小值取绝对值即可。
#include <cstdlib>#include <cstdio>char temp[100];int main(){int v,front,now;while ( scanf("%d%s",&front,temp) ) {scanf("%s%d",temp,&v);if ( !v ) break;int leak = 0;double tank = 0.0,Min = 0.0;do {scanf("%d%s",&now,temp);tank = tank - v*(now-front)/100.0 - leak*(now-front);if ( tank < Min ) Min = tank;front = now;if ( temp[0] == 'L' ) leak ++;if ( temp[0] == 'M' ) leak = 0;if ( temp[0] == 'F' ) scanf("%s%d",temp,&v);if ( temp[1] == 'a' ) {scanf("%s",temp);tank = 0;}}while ( temp[1] != 'o' || temp[2] != 'a' );printf("%.3lf\n",-1*Min);}return 0;}
0 0
- UVa 11935 - Through the Desert
- UVa OJ 11935-Through the Desert
- Walk Through the Forest UVA
- Paths through the Hourglass UVA
- uva 10564 Paths through the Hourglass
- uva 10564 Paths through the Hourglass
- UVA 10564 Paths through the Hourglass
- Uva 10917 Walk Through the Forest
- UVA 10564 Paths through the Hourglass
- UVA 10917 Walk Through the Forest
- UVA 10564 - Paths through the Hourglass
- UVA 10564 - Paths through the Hourglass (dp)
- UVA 10564 Paths through the Hourglass
- UVA 10564 Paths through the Hourglass
- UVA 10564 Paths through the Hourglass
- UVA 10564 Paths through the Hourglass
- UVa:10564 Paths through the Hourglass
- uva 10564 - Paths through the Hourglass(dp)
- DATAGUARD-启动和关闭操作
- javascript常用函数大全
- 如何量化消费者满意度指标
- myeclipse中maven3的使用,部署web项目到tomcat7
- Delphi使用JSON
- UVa 11935 - Through the Desert
- AlarmManager
- C语言 命令行参数 函数指针 gdb调试
- StartActivity
- 将jeecms源码导入eclipse工程
- JDK源码阅读之String
- js中apply使用方法小议
- shell脚本中echo显示内容带颜色
- BeanUtils.copyProperties()的用法