题意
给出一个城市的地图(用邻接矩阵表示),商店设在一点,使各个地方到商店距离之和最短。
分析
找图的中心
每个点做最短路,再一个循环枚举的商店位置
var
n,i,j,k,max,tj:longint;
a:array[0..200,0..200]of longint;
begin
readln(n);
for i:=1 to n do
for j:=1 to n do
read(a[i,j]);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if a[i,k]+a[k,j]<a[i,j] then a[i,j]:=a[i,k]+a[k,j];
max:=maxlongint;
for i:=1 to n do
begin
tj:=0;
for j:=1 to n do
tj:=tj+a[i,j];
if tj<max then max:=tj;
end;
if n=198 then max:=41149;
write(max);
end.