import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main2775 {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(bf.readLine());
int[][] apt = new int[15][15];
for(int i=0; i<15; i++){
apt[i][1] = 1;
apt[0][i] = i;
}
for(int i=1; i<15; i++){
for(int j=2; j<15; j++){
apt[i][j] = apt[i][j-1] + apt[i-1][j]; // -1호 + 아래층 호의 합
}
}
for(int i=0; i<T; i++){
int k = Integer.parseInt(bf.readLine());
int n = Integer.parseInt(bf.readLine());
System.out.println(apt[k][n]);
}
}
}
각층의 조건은 자기 옆호 (-1호) + 자기 바로 아래층 호의 사람수 합 을 구하면 풀 수 있다.
'휴지통 > 알고리즘 & 자료구조' 카테고리의 다른 글
백준 2839 (0) | 2021.08.03 |
---|---|
로또의 최고 순위와 최저 순위 [Java] (0) | 2021.07.31 |
백준 2750 (0) | 2021.07.28 |
백 트래킹(Back Tracking) (0) | 2021.07.24 |
백준 10250 (0) | 2021.07.22 |