解题思路
相关代码
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int nums[][] = new int[n+1][n+1];
while(true){
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
nums[a][b]=c;
if(a==0&&b==0&&c==0) break;
}
//f[k][i1][i2] k表示的是走了多少步 i1表示第一条路径的,i2表示第二条路径
int f[][][] = new int[2*n+1][n+1][n+1];
for(int k=2;k<=2*n;k++){
for(int i1=1;i1<=n;i1++){
for(int i2=1;i2<=n;i2++){