expedition(探险)(python)
发布日期:2022-03-08 21:50:40 浏览次数:4 分类:技术文章

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

题目

A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run over a rock and puncture the truck’s fuel tank. The truck now leaks one unit of fuel every unit of distance it travels.

To repair the truck, the cows need to drive to the nearest town (no more than 1,000,000 units distant) down a long, winding road. On this road, between the town and the current location of the truck, there are N (1 <= N <= 10,000) fuel stops where the cows can stop to acquire additional fuel (1…100 units at each stop).

The jungle is a dangerous place for humans and is especially dangerous for cows. Therefore, the cows want to make the minimum possible number of stops for fuel on the way to the town. Fortunately, the capacity of the fuel tank on their truck is so large that there is effectively no limit to the amount of fuel it can hold. The truck is currently L units away from the town and has P units of fuel (1 <= P <= 1,000,000).

Determine the minimum number of stops needed to reach the town, or if the cows cannot reach the town at all.

一群奶牛抢了一辆卡车决定前往树林里探险。但是由于他们的驾驶技术太糟,油箱在路上弄破了,所以他们每前进一个单位的路程就会漏掉一个单位的油。为了修好油箱,奶牛们必须前往最近的城市(不会超过1000000单位路程)。在当前位置和城市之间有N个加油站,奶牛可以在加油站加1到100单位的油。

对于人来说,树林是危险的地方,对奶牛来说,更是这样,所以奶牛门尽可能的少停站加油,幸运的是,这辆卡车的油箱非常大,你可以认为它的容量是无限大的。卡车在离城市P单位时还有L个单位的油。

你要计算出奶牛们至少要停几站才能到城市,或者奶牛们根本到不了城市。

代码

a=[10,14,20,21]b=[10,5,2,4]n=4;l=25;p=10c=[]k=1;i=0num=0while i

转载地址:https://blog.csdn.net/m0_55510656/article/details/122769003 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:周期串快速实现(python)
下一篇:蓝桥杯2013年第四届真题-打印十字图(python)

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年03月20日 22时43分43秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

android日期选择区间控件_Android时间区间的选择 2019-04-21
lin通讯从节点同步间隔场_LIN模块介绍 2019-04-21
mysql注入提取邮件_Mysql提取数据每日自动邮件通知 2019-04-21
mysql 列权限_mysql 权限相关 2019-04-21
手机端 vue+vant datetime支持时分秒_vueCli4+vant+router+vuex+移动端适配 2019-04-21
kafka消费者直接存在mysql中_【Canal】利用canal实现mysql实时增量备份并对接kafka 2019-04-21
python中readlines()函数_python中读取文件函数read()、readline()、readlines()的区别 2019-04-21
python入门之基础语法第四关输入输出答案_Python基本语法入门,基础 2019-04-21
mysql在存储过程仍_mysql存储过程 2019-04-21
失败的人生图片_早安励志经典语录精辟的一句话人生感悟 2019-04-21
如何设画面大小_如何设计旅游类项目?分享3种设计思路 2019-04-21
开启web_2021秋招四大网申时间、网申地址汇总(持续更新),德勤、安永、普华永道已开启!... 2019-04-21
从右边开始放_停路边,被人恶意放钉子,爆胎,报警无果,要我找监控 2019-04-21
读写测试_UFS 3.0读写测试数据曝光:秒杀UFS 2.1和eMMC 2019-04-21
注册小程序要多少钱_开发一个微信小程序商城要多少钱? 2019-04-21
mysql 实现id自增序列_MySQL分表自增ID解决方案 2019-04-21
反距离加权插值法例题_空间插值算法-反距离加权法 2019-04-21
oracle如何写循环日期自增_Oracle动态创建时间分区,以及Oracle12c中快速创建自增列... 2019-04-21
手机gps信息提取并储存到本地_通信人的实用技巧,如何在日常拍的照片里提取GPS位置信息... 2019-04-21
mysql5717开发设置怎么调回来_mysql 5.7.17 安装配置方法图文教程 2019-04-21