#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int N,a[1001][1001],b[1001];
int main()
{
int i,j;
cin>>N;
memset(a,0x7f,sizeof(a));
memset(b,0x7f,sizeof(b));
b[1]=0;
for(i=1;i<=N;i++)
for(j=1;j<=N;j++)
cin>>a[i][j];
for(i=2;i<=N;i++)//从城市2开始遍历
for(j=i;j>=1;--j)//之前的城市都有可能到达他
b[i]=min(a[j][i]+b[j],b[i]);//取最小值。
cout<<"minlong="<<b[N];
return 0;
}
从城市A到N的最短路径
输入
第x+1行第y列代表第x个城市到第y个城市的路
10
0 2 5 1 0 0 0 0 0 0
0 0 0 0 12 14 0 0 0 0
0 0 0 0 6 10 4 0 0 0
0 0 0 0 13 12 11 0 0 0
0 0 0 0 0 0 0 3 9 0
0 0 0 0 0 0 0 6 5 0
0 0 0 0 0 0 0 0 10 0
0 0 0 0 0 0 0 0 0 5
0 0 0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 0 0 0
输出
minlong=19