재밌고 어려운 IT를 이해해보자~!
[백준] 1010 본문
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int[][] arr = new int[30][30];
for (int i = 0; i < 30; i++) {
arr[0][i] = i + 1;
}
for (int i = 1; i < 30; i++) {
for (int j = 0; j < 30; j++) {
if (j <= i) {
arr[i][j] = 1;
} else {
arr[i][j] = arr[i][j - 1] + arr[i - 1][j - 1];
}
}
}
int T = Integer.parseInt(br.readLine());
int[] ans = new int[2];
for (int a = 0; a < T; a++) {
String[] temp = br.readLine().split(" ");
for (int i = 0; i < 2; i++) {
ans[i] = Integer.parseInt(temp[i]);
}
System.out.println(arr[ans[0] - 1][ans[1] - 1] + " ");
}
}
}
'알고리즘' 카테고리의 다른 글
코딩테스트 풀어보기! (0) | 2024.05.28 |
---|---|
[백준] 2775 (0) | 2024.05.26 |
[백준] 17287 (0) | 2024.05.19 |
[백준] 1927 (0) | 2024.05.18 |
[백준] 풀이 (0) | 2023.12.14 |
Comments