-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10099.cpp
More file actions
49 lines (46 loc) · 739 Bytes
/
10099.cpp
File metadata and controls
49 lines (46 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<stdio.h>
#include<math.h>
long max(long a,long b)
{
if(a>b) return a;
else return b;
}
long min(long a,long b)
{
if(a<b) return a;
else return b;
}
long i,j,k,cost,w[110][110],n,r,u,v,t=1;
double cst;
int main()
{
while(~scanf("%ld%ld",&n,&r)&&(n||r))
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
w[i][j]=0;
}
for(i=1;i<=r;i++)
{
scanf("%ld%ld%ld",&u,&v,&cost);
w[u][v]=w[v][u]=cost;
}
for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
w[i][j]=max(w[i][j],min(w[i][k],w[k][j]));
}
}
}
scanf("%ld%ld%ld",&u,&v,&cost);
printf("Scenario #%ld\n",t++);
cst=w[u][v]-1;
cst=ceil(cost/cst);
printf("Minimum Number of Trips = %.0lf\n\n",cst);
}
return 0;
}