The Tourist Guide (旅游指南)

 https://cn.vjudge.net/problem/UVA-10099

 Mr. G. works as a tourist guide. His current assignment is to take some tourists from one city to another. Some two-way roads connect the cities. For each pair of neighboring cities there is a bus service that runs only between those two cities and uses the road that directly connects them. Each bus service has a limit on the maximum number of passengers it can carry. Mr. G. has a map showing the cities and the roads connecting them. He also has the information regarding each bus service. He understands that it may not always be possible for him to take all the tourists to the destination city in a single trip. For example, consider the following road map of 7 cities. The edges connecting the cities represent the roads and the number written on each edge indicates the passenger limit of the bus service that runs on that road.

 

                           

Now, if he wants to take 99 tourists from city 1 to city 7, he will require at least 5 trips, since he has to ride the bus with each group, and the route he should take is : 1 - 2 - 4 - 7.

But, Mr. G. finds it difficult to find the best route all by himself so that he may be able to take all the tourists to the destination city in minimum number of trips. So, he seeks your help.

 

Input

The input will contain one or more test cases. The first line of each test case will contain two integers: N (N<= 100) and R representing respectively the number of cities and the number of road segments. Then R lines will follow each containing three integers: C1, C2 and P. C1 andC2 are the city numbers and P (P> 1) is the limit on the maximum number of passengers to be carried by the bus service between the two cities. City numbers are positive integers ranging from 1 to N. The (R + 1)-th line will contain three integers: S, D and T representing respectively the starting city, the destination city and the number of tourists to be guided.

The input will end with two zeroes for N and R.

 

Output

For each test case in the input first output the scenario number. Then output the minimum number of trips required for this case on a separate line. Print a blank line after the output of each test case.

 

题意:n个点,r条路径,每条路径最多通过人数最多为v人,

求把v个游客从a点运送到b点,需要几辆车,!!!注意导游自己也算一个人!!!

思路:floyd找出两点间最大运送量,然后计算需要几躺即可

Code:

#include
#include
#include
using namespace std;
int map[110][110];
int main()
{
    int n,r,k=1;
    while(~scanf("%d %d",&n,&r)&&(n+r))
    {
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
                map[i][j]=map[j][i]=-1;
                int a,b,v;
        for(int i=0; i

附图:

↖(^ω^)↗

The Tourist Guide (旅游指南)_第1张图片 (⊙v⊙)嗯!~

逝者如斯夫,不舍昼夜是孔子的一句名言,形容时间像流水一样不停地流逝,一去不复返,感慨人生世事变化之快,亦有惜时之意在其中。出自论语《子罕》。

你可能感兴趣的:(最短路)