녕의 학습 기록
백준_2775 부녀회장이 될테야 (조합) 본문
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BJ_2775_부녀회장이될테야 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
int [][] d = new int[15][15];
int i;
for (i=0; i<15; i++) {
d[0][i] = i;
d[i][1] = 1;
}
int j;
for (i=1; i<15; i++) {
for (j=2; j<15; j++) {
d[i][j] = d[i][j-1] + d[i-1][j];
}
}
StringBuilder result = new StringBuilder();
int k, n;
for (i=0; i<t; i++) {
k = Integer.parseInt(br.readLine());
n = Integer.parseInt(br.readLine());
result.append(d[k][n]).append('\n');
}
System.out.println(result);
}
}
2775번: 부녀회장이 될테야
첫 번째 줄에 Test case의 수 T가 주어진다. 그리고 각각의 케이스마다 입력으로 첫 번째 줄에 정수 k, 두 번째 줄에 정수 n이 주어진다
www.acmicpc.net
'Algorithm > Algorithm 문제' 카테고리의 다른 글
백준_13251 조약돌 꺼내기 (0) | 2024.04.01 |
---|---|
백준_1010 다리 놓기 (1) | 2024.04.01 |
백준_11051 이항 계수 2 (조합) (0) | 2024.03.26 |
백준_11050 이항 계수 1 (조합) (0) | 2024.03.24 |
백준_11438 LCA2 (빠른 최소 공통 조상) (0) | 2024.03.19 |