PAT 1033. To Fill or Not to Fill】的更多相关文章

PAT甲级1033. To Fill or Not to Fill 题意: 有了高速公路,从杭州到任何其他城市开车很容易.但由于一辆汽车的坦克容量有限,我们不得不在不时地找到加油站.不同的加油站可能会给不同的价格.您被要求仔细设计最便宜的路线. 输入规格: 每个输入文件包含一个测试用例.对于每种情况,第一行包含4个正数:Cmax(<= 100),坦克的最大容量; D(<= 30000),杭州与目的地城市的距离; Davg(<= 20),汽车可以运行的单位气体的平均距离;和N(<=…
1033. To Fill or Not to Fill (25) 时间限制 10 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 ZHANG, Guochuan With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to fin…
1033 To Fill or Not to Fill(25 分) With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may gi…
1033 To Fill or Not to Fill (25 分)   With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may…
1033 To Fill or Not to Fill With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give dif…
PAT A 1033 To Fill or Not to Fill With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may gi…
 题目链接:http://www.patest.cn/contests/pat-a-practise/1033 题目: 1033. To Fill or Not to Fill (25) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 ZHANG, Guochuan With highways available, driving a car from Hangzhou to any other city is easy. But…
1033 To Fill or Not to Fill (25 分) With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may g…
1033. To Fill or Not to Fill (25) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 ZHANG, Guochuan With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to fin…
Source: PAT A1033 To Fill or Not to Fill (25 分) Description: With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. D…
题目1437:To Fill or Not to Fill 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:1488 解决:345 题目描述: With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way fro…
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1033 此题是一道贪心算法题,难度较大,关键在于贪心策略的选择: #include <cstdio> #include <vector> #include <algorithm> #include <climits> using namespace std; struct GasStation { double price; double distance…
#include <cstdio> #include <cstdlib> #include <vector> #include <algorithm> using namespace std; int main() { int N; double mcap, dist, davg; scanf("%lf%lf%lf%d", &mcap, &dist, &davg, &N); double price, id…
PAT-A最后一个问题.最后做出来... 贪婪,通过局部优化全局优化. 1. 该加油站按距离升序排列 2. 记录气体台当前所在index,目前的汽油.开支.在您的整个背部 3. 遍历中有两种情况: 1) 若发现油价比index更低的站next: 立即跳到该站(此时可能须要加油),不再继续遍历 -- 由于即使想要到达next后面的站,能够通过在next站购买更廉价的汽油来实现 2) 没有发现油价比index更低的站,则选择全部站中油价最低的站作为next: 此时考虑能否通过index抵达终点,若能…
模拟先说一下例子,最后为方便起见,在目的地安增加一个费用为0的加油站0 1 2 3 4 5 6 7 87.1 7.0 7.2 6.85 7.5 7.0 7.3 6.0 00 150 200 300 400 600 1000 1250 1300车子加满了最多开50*12=600的距离0.第0个加油站600以内中,找有没有比7.1小的找到7.0,那么只需要加跑150距离的汽油即可费用(150/12)*7.1=88.75到第1个加油站 1.同样往后600距离内找比7.0小的找到6.85,那么只需要加跑…
PAT-A的最后一题,最终做出来了... 是贪心,通过局部最优获得全局最优. 1. 将加油站按距离升序排序 2. 记录当前所在的加油站index,存有的汽油,花费.向后遍历全部 该站可抵达的加油站 3. 遍历中有两种情况: 1) 若发现油价比index更低的站next: 立即跳到该站(此时可能须要加油),不再继续遍历 -- 由于即使想要到达next后面的站,能够通过在next站购买更廉价的汽油来实现 2) 没有发现油价比index更低的站,则选择全部站中油价最低的站作为next: 此时考虑能否通…
贪心.注意x=0处没有加油站的情况. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; struct X { double cost, x, v; int…
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked…
题意: 输入四个正数C,DIS,D,N(C<=100,DIS<=50000,D<=20,N<=500),分别代表油箱容积,杭州到目标城市的距离,每升汽油可以行驶的路程,加油站数量.接下来输入N行数据,每行包括一个小数代表该加油站每升汽油的价格和该加油站距离杭州的距离.输出杭州到该城市的最小加油花费,如果到不了的话输出离开杭州的最远路程. 思路: 每次到一个加油站时都把油箱加满,如果加油站i油箱加满所能行驶的范围内有加油站j油价比i便宜,那么j位置的花费就为i位置的花费减去(油箱加满…
题目 With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Diferent gas station may give diferent price. You are asked…
题目 With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are ask…
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked…
题目描写叙述 With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are…
题目如下: With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are…
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked…
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked…
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked…
1033 旧键盘打字(20)(20 分) 旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在2行中分别给出坏掉的那些键.以及应该输入的文字.其中对应英文字母的坏键以大写给出:每段文字是不超过10^5^个字符的串.可用的字符包括字母[a-z, A-Z].数字0-9.以及下划线"_"(代表空格).","."."."-".&qu…
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在2行中分别给出坏掉的那些键.以及应该输入的文字.其中对应英文字母的坏键以大写给出:每段文字是不超过105个字符的串.可用的字符包括字母[a-z, A-Z].数字0-9.以及下划线"_"(代表空格).","."."."-"."+"(代表上档键).题目保证第…
题目描述: With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are…