¶
기 ... 간거 ..
거!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
거!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
~cpp
#include <iostream>
#include <Windows.h>
#include <vector>
#include <cmath>
using namespace std;
bool IsCanPut(int baseBallNumber, int putBallNumber)
{
double sqrtNumber = sqrt((double)(baseBallNumber + putBallNumber));
if (sqrtNumber == (double)(int)sqrtNumber)
return TRUE;
return FALSE;
}
int GetMaxBallNumber(int stickNumber)
{
int ballCount = 0;
vector<int> lastBallNumbers;
lastBallNumbers.resize(stickNumber);
while(1)
{
bool isPut = FALSE;
for (register int i = 0; i < stickNumber; ++i)
{
if (IsCanPut(lastBallNumbers[i], ballCount + 1) || 0 == lastBallNumbers[i])
{
isPut = TRUE;
lastBallNumbers[i] = ballCount + 1;
++ballCount;
break;
}
}
if (FALSE == isPut)
return ballCount;
}
}
void main()
{
int testCaseNumber;
cin >> testCaseNumber;
for (int i = 0; i < testCaseNumber; ++i)
{
int stickNumber;
cin >> stickNumber;
cout << GetMaxBallNumber(stickNumber) << endl;
}
}










