본문 바로가기

Programming/BaekJoon

[C++] 백준 2775번 : 부녀회장이 될테야


https://www.acmicpc.net/problem/2775




#include <iostream>

using namespace std;

int main() {

int Apt[14][14];

for (int i = 0; i < 14; i++)

Apt[0][i] = i + 1;


int num;

cin >> num;

int *T_c = new int[num];


for (int m = 0; m < num; m++) {

int k, n; //k층, n호

cin >> k >> n;

k++;

int tmp;

for (int i = 1; i < k; i++) {

for (int j = 0; j < n; j++) {

tmp = 0;

for (int l = 0; l <= j; l++)

tmp = Apt[i - 1][l] + tmp;

Apt[i][j] = tmp;

}

}

T_c[m] = Apt[k-1][n-1];

}


for (int m = 0; m < num; m++) 

cout << T_c[m] << "\n";


}