[코드有] 이거 안되는 예제 좀 주실 수 있나요? 진짜 오늘 하루종일 이거만 붙잡고 있었는

990299 Reply 8 years 26 weeks ago
package com; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int d, i, j, k; int trash = 0; long temp; int R[] = new int[1010]; long M[][] = new long[10100][10100]; for (int h = 0; h < N; h++) { if(h != N - 1) { R[h] = sc.nextInt(); trash = sc.nextInt(); } else { R[h] = sc.nextInt(); R[h + 1] = sc.nextInt(); } } for (d = 1; d <= N - 1; d++) { long min = 10000000; for (i = 1; i <= N - d; i++) { j = d + i; for (k = i; k < j; k++) { temp = M[i][k] + M[k+1][j] + R[i-1]*R[k]*R[j]; if (min > temp) { min = temp; } M[i][j] = min; int a = i; int b = j; if (a != i || b != j) min = 10000000; } } } System.out.println(M[1][N]); } }
990299 Reply 8 years 26 weeks ago
어셉 받았습니당
onacloud Reply 8 years 25 weeks ago
오 ^^; 감사합니다.