백준 2775번 (부녀회장 점화식)

김경욱·2025년 8월 28일

백준

목록 보기
64/121

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.*;

public class Main {

public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   int N = Integer.parseInt(br.readLine());

   int[][] people = new int[15][15];






   int[] sum = new int[200];

   for (int i = 1 ; i  <= 14; i++)
   {
      people[0][i] = i;
   }

   for (int i = 1 ; i <= 14; i++)
   {
       for (int j = 1; j <= 14; j++)
       {
           people[i][j] = people[i-1][j]+people[i][j-1];
       }
   }


    for (int i = 0 ; i <  N; i++)
    {
        int a = Integer.parseInt(br.readLine());
        int b = Integer.parseInt(br.readLine());


        System.out.println(people[a][b]);
    }







}

}

점화식을 이용해서 문제를 푸는 문제였다. 점화식 발상이 대단한 것 같다. people[i][j] = people[i-1][j] + people[i][j-1] 발상은 "와"하는 소리가 나올정도로 대단했다.

0개의 댓글