please check this problem of program challenges book

#include <stdio.h>

#include <math.h>

#define MAX 102

#define NEGINF -10000

#define max(a, b) ( (a > b) ? (a) : (b) )

#define min(a, b) ( (a < b) ? (a) : (b) )

long passengers[MAX][MAX];

void init( long roads ) {

long i, j;

for( i = 1; i <= roads; ++i )

for( j = 1; j <= roads; ++j )

passengers[i][j] = NEGINF;

}

int main()

{

long cities, roads, road1, road2;

long i, j, k, scinario = 0;

long source, des, totalPassengers;

scanf( "%ld%ld", &cities, &roads );

while( cities && roads )

{

init( roads );

for( i = 0; i < roads; ++i ){

scanf( "%ld%ld", &road1, &road2 );

scanf( "%ld", &passengers[road1][road2] );

passengers[road2][road1] = passengers[road1][road2];

}

scanf( "%ld%ld%ld", &source, &des, &totalPassengers );

for( k = 1; k <= cities; ++k )

for( i = 1; i <= cities; ++i )

for( j = 1; j <= cities; ++j )

passengers[i][j] = max( passengers[i][j], min( passengers[i][k], passengers[k][j]));

printf( "Scenario #%ldnMinimum Number of Trips = %.0lfnn", ++scinario,

ceil( double(totalPassengers) / ( passengers[source][des] - 1 )));

scanf( "%ld%ld", &cities, &roads );

}

return 0;

}#include <stdio.h>

#include <math.h>

#define MAX 102

#define NEGINF -10000

#define max(a, b) ( (a > b) ? (a) : (b) )

#define min(a, b) ( (a < b) ? (a) : (b) )

long passengers[MAX][MAX];

void init( int roads ) {

int i, j;

for( i = 1; i < MAX; ++i )

for( j = 1; j < MAX; ++j )

passengers[i][j] = 0;

}

int main()

{

long cities, roads, road1, road2;

long i, j, k, scinario = 0;

long source, des, totalPassengers;

scanf( "%ld%ld", &cities, &roads );

while( cities && roads )

{

init( roads );

for( i = 0; i < roads; ++i ){

scanf( "%ld%ld", &road1, &road2 );

scanf( "%ld", &passengers[road1][road2] );

passengers[road2][road1] = passengers[road1][road2];

}

scanf( "%ld%ld%ld", &source, &des, &totalPassengers );

for( k = 1; k <= cities; ++k )

for( i = 1; i <= cities; ++i )

for( j = 1; j <= cities; ++j )

passengers[i][j] = max( passengers[i][j], min( passengers[i][k], passengers[k][j]));

printf( "Scenario #%ldnMinimum Number of Trips = %.0lfnn", ++scinario,

ceil( double(totalPassengers) / ( passengers[source][des] - 1 )));

scanf( "%ld%ld", &cities, &roads );

}

return 0;

}

#include <stdio.h>

#include <math.h>

#define MAX 102

#define NEGINF -10000

#define max(a, b) ( (a > b) ? (a) : (b) )

#define min(a, b) ( (a < b) ? (a) : (b) )

long passengers[MAX][MAX];

void init( long roads ) {

long i, j;

for( i = 1; i <= roads; ++i )

for( j = 1; j <= roads; ++j )

passengers[i][j] = NEGINF;

}

int main()

{

long cities, roads, road1, road2;

long i, j, k, scinario = 0;

long source, des, totalPassengers;

scanf( "%ld%ld", &cities, &roads );

while( cities && roads )

{

init( roads );

for( i = 0; i < roads; ++i ){

scanf( "%ld%ld", &road1, &road2 );

scanf( "%ld", &passengers[road1][road2] );

passengers[road2][road1] = passengers[road1][road2];

}

scanf( "%ld%ld%ld", &source, &des, &totalPassengers );

for( k = 1; k <= cities; ++k )

for( i = 1; i <= cities; ++i )

for( j = 1; j <= cities; ++j )

passengers[i][j] = max( passengers[i][j], min( passengers[i][k], passengers[k][j]));

printf( "Scenario #%ldnMinimum Number of Trips = %.0lfnn", ++scinario,

ceil( double(totalPassengers) / ( passengers[source][des] - 1 )));

scanf( "%ld%ld", &cities, &roads );

}

return 0;

}#include <stdio.h>

#include <math.h>

#define MAX 102

#define NEGINF -10000

#define max(a, b) ( (a > b) ? (a) : (b) )

#define min(a, b) ( (a < b) ? (a) : (b) )

long passengers[MAX][MAX];

void init( int roads ) {

int i, j;

for( i = 1; i < MAX; ++i )

for( j = 1; j < MAX; ++j )

passengers[i][j] = 0;

}

int main()

{

long cities, roads, road1, road2;

long i, j, k, scinario = 0;

long source, des, totalPassengers;

scanf( "%ld%ld", &cities, &roads );

while( cities && roads )

{

init( roads );

for( i = 0; i < roads; ++i ){

scanf( "%ld%ld", &road1, &road2 );

scanf( "%ld", &passengers[road1][road2] );

passengers[road2][road1] = passengers[road1][road2];

}

scanf( "%ld%ld%ld", &source, &des, &totalPassengers );

for( k = 1; k <= cities; ++k )

for( i = 1; i <= cities; ++i )

for( j = 1; j <= cities; ++j )

passengers[i][j] = max( passengers[i][j], min( passengers[i][k], passengers[k][j]));

printf( "Scenario #%ldnMinimum Number of Trips = %.0lfnn", ++scinario,

ceil( double(totalPassengers) / ( passengers[source][des] - 1 )));

scanf( "%ld%ld", &cities, &roads );

}

return 0;

}

## This question was asked on May 30, 2010.

### Recently Asked Questions

- Please refer to the attachment to answer this question. This question was created from practice midterm1_Spring 2018.pdf.

- Please refer to the attachment to answer this question. This question was created from practice midterm1_Spring 2018.pdf.

- Please refer to the attachment to answer this question. This question was created from SSTH_007_058-Project3.