녕의 학습 기록

백준_2775 부녀회장이 될테야 (조합) 본문

Algorithm/Algorithm 문제

백준_2775 부녀회장이 될테야 (조합)

kjyyjk 2024. 3. 28. 14:33

 

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