V+1로 캐퍼시티를 잡아 1~V까지 사용하지만
'0'개를 뽑는 것도 공간에 들어가므로 0부터 시작한다
왜 2부터 시작인가?
왜 J < I 인가?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// ISC
Scanner sc = new Scanner(System.in);
int V = sc.nextInt();
// D2F
int K = sc.nextInt();
int[][] TP = new int[V+1][V+1];
// O1 : sP
for (int i = 0; i <= V; i++) {
TP[i][1] = i;
TP[i][0] = 1;
TP[i][i] = 1;
}
// O2
for (int i = 2; i <= V; i++) {
for (int j = 1; j < i; j++) {
TP[i][j] = TP[i-1][j] + TP[i-1][j-1];
TP[i][j] = TP[i][j] % 10007;
}
}
// OEC
System.out.println(TP[V][K]);
}
}
'Hard deck > reindexing d3' 카테고리의 다른 글
080 : 조약돌 꺼내기 (0) | 2023.06.28 |
---|---|
079 : 다리 놓기 (0) | 2023.06.28 |
019 : Quick sort / K번째 수 구하기 (0) | 2023.06.28 |
018 : ATM 인출 시간 / insertion sort (0) | 2023.06.27 |
017 : selection sort / 내림차순 (0) | 2023.06.27 |