소스 ¶
~cpp
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int GetMaxTryNumber(int buildingHeight, int tryNumber)
{
int countNumber = 0;
vector<int> nodes;
nodes.resize(tryNumber + 1);
nodes[tryNumber] = 1;
while (accumulate(nodes.begin(), nodes.end(), 0) <= buildingHeight)
{
++countNumber;
for (register int i = 1; i < (int)nodes.size(); ++i)
nodes[i - 1] += nodes[i];
}
return countNumber;
}
void main()
{
int testNumber;
cin >> testNumber;
for (register int i = 0; i < testNumber; ++i)
{
int buildingHeight;
int tryNumber;
cin >> buildingHeight;
cin >> tryNumber;
cout << GetMaxTryNumber(buildingHeight, tryNumber) << endl;
}
}