알고리즘
백준 2775번 부녀회장이 될테야
hyun0229
2022. 4. 6. 11:30
https://www.acmicpc.net/problem/2775
2775번: 부녀회장이 될테야
첫 번째 줄에 Test case의 수 T가 주어진다. 그리고 각각의 케이스마다 입력으로 첫 번째 줄에 정수 k, 두 번째 줄에 정수 n이 주어진다
www.acmicpc.net
#include <iostream>
static int Test_Case(int x, int y) {
int n[14] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
for (int i = 1; i < x + 1; i++)
{
for (int a = y - 1; a >= 1; a--)
{
for (int b = 1; b <= a; b++)
{
n[a] += n[a - b];
}
}
}
return n[y - 1];
}
int main()
{
int x, y, t = 0;
std::cin >> t;
for (int i = 0; i < t; i++)
{
std::cin >> x;
std::cin >> y;
std::cout << Test_Case(x, y) << "\n";
}
}
제가 제출한 코드입니다.
