문제
접근방법
구현
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine(), " ", false);
int N = Integer.parseInt(st.nextToken());
int K = Integer.parseInt(st.nextToken());
int[][] dp = new int[N + 1][N + 1];
for (int i = 0; i < dp.length; i++) {
for (int j = 0; j <= i; j++) {
if (i == j || j == 0) {
dp[i][j] = 1;
} else {
dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % 10007;
}
}
}
bw.write(dp[N][K] + "");
bw.close();
}
}
제출