Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms.
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connected to some other farm such that a path exists from any farm to any other farm.
INPUT FORMAT:
The first line of input is the number of farms, N (3 <= N <= 100).
Each
line i of N subsequent lines contains N non-negative integers
(each less
than 32000) that represent the distance between farm i and farms 1, 2,
3, ..., N. Of course, the diagonal will be 0, since the distance from
farm i to itself is not interesting for this problem.
SAMPLE INPUT (file INPUT.TXT):
4 0 4 9 21 4 0 8 17 9 8 0 16 21 17 16 0
OUTPUT FORMAT:
The single output contains the integer length that is the sum of
the minimum length of fiber required to connect the entire set of
farms.
SAMPLE OUTPUT (file OUTPUT.TXT):
28
| Updated February 3, 1999 | Frames On |
John Danaher <jdanaher@tjhsst.edu> |