백준 2225 java : DP

import java.util.Arrays;
import java.util.Scanner;
public class bj2225 {
public static Scanner scanner = new Scanner(System.in);
public static void main(String []args){
int N;
int K;
N = scanner.nextInt();
K = scanner.nextInt();
System.out.println(findAnswer(N, K));
scanner.close();
}
public static int findAnswer(int N, int K){
System.out.println("findAnswer()");
int answer = 0;
int[][] DP = new int[K + 1][N + 1];
int i, j;
int MOD = 1000000000;
//0부터 N까지의 정수 K개를 더해서 그 합이 N이 되는 경우
//20 2가 입력되면 (0, 20) (1, 19) (2, 18), ... (20, 0) 21개가 나와야 함
//K개의 숫자로 0을 만드는 방법은 숫자 0만 사용하는 경우 1개
for(i = 1; i <= K; i++){
DP[i][0] = 1;
}
for(i = 1; i <= K; i++){
for(j = 1; j <= N; j++){
DP[i][j] = DP[i - 1][j];
if(j >= 1){
DP[i][j] += DP[i][j - 1];
}
DP[i][j] = DP[i][j] % MOD;
}
for(j = 1; j <= N; j++){
System.out.print(DP[i][j] + " ");
}
System.out.println();
}
answer = DP[K][N];
return answer;
}
}