No older revisions available
No older revisions available
느낀점 및 설명 ¶
기다리는 동안 심심해서... 간단한거 하나..
왜 아무도 않오는 거야앗!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
왜 아무도 않오는 거야앗!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
소스 ¶
~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; } }