文件名称:qichejiayouwenti
介绍说明--下载内容均来自于网络,请自行研究使用
问题描述:一辆汽车加满油后可以行驶nkm ,旅途中有若干个加油站,设计一个有效的算法,指出应在哪些加油站停靠加油,使沿途加油次数最少。
算法设计:对于给定的n和k个加油站位置,计算最少加油次数。
数据输入 由文件input.txt给出输入数据。第一行有2个正整数n和k,表示汽车加油后可以行驶的nkm,且旅途中有k个加油 站,接下来的一行中有k+1个整数,表示第k个加油站与k-1个加油站之间的距离,第0个加油站表示出发地,汽车已加满油。第k+1个加油站表示目的地,
结果输出:将计算的最少加油次数输出到文件output.txt 如果无法到达目的地则输出”no solution“.
输入文件示例: 输出文件示例:
input.txt output.txt
7 7 4
1 2 3 4 5 1-Problem Descr iption: After the fill up a car can travel nkm, the road there are several gas stations, to design an effective algorithm
That should stop refueling stations in which to refuel along the least number.
Algorithm Design: For a given n and k a gas station location, calculate the number of minimum fuel.
Data entry input data given by the file input.txt. The first line has two positive integers n and k, that can travel after the vehicle refueling
The nkm, and k gas stations in the journey, the next line of k+1 integers in that the first k-k-1 gas station with fuel pump
The distance between stations, gas stations, said the starting 0, the car has been fill up. K+1 gas stations, said first destination,
The resulting output: the calculation of the minimum number of fuel output to the file output.txt If you can not reach the destination, the output "no
solution ".
Input file: output file:
input.txt output.txt
774
12,345,166
算法设计:对于给定的n和k个加油站位置,计算最少加油次数。
数据输入 由文件input.txt给出输入数据。第一行有2个正整数n和k,表示汽车加油后可以行驶的nkm,且旅途中有k个加油 站,接下来的一行中有k+1个整数,表示第k个加油站与k-1个加油站之间的距离,第0个加油站表示出发地,汽车已加满油。第k+1个加油站表示目的地,
结果输出:将计算的最少加油次数输出到文件output.txt 如果无法到达目的地则输出”no solution“.
输入文件示例: 输出文件示例:
input.txt output.txt
7 7 4
1 2 3 4 5 1-Problem Descr iption: After the fill up a car can travel nkm, the road there are several gas stations, to design an effective algorithm
That should stop refueling stations in which to refuel along the least number.
Algorithm Design: For a given n and k a gas station location, calculate the number of minimum fuel.
Data entry input data given by the file input.txt. The first line has two positive integers n and k, that can travel after the vehicle refueling
The nkm, and k gas stations in the journey, the next line of k+1 integers in that the first k-k-1 gas station with fuel pump
The distance between stations, gas stations, said the starting 0, the car has been fill up. K+1 gas stations, said first destination,
The resulting output: the calculation of the minimum number of fuel output to the file output.txt If you can not reach the destination, the output "no
solution ".
Input file: output file:
input.txt output.txt
774
12,345,166
(系统自动生成,下载前可以参看下载内容)
下载文件列表
qichejiayouwenti.cpp