#C4588. Smallest k for Sum of Squares
Smallest k for Sum of Squares
Smallest k for Sum of Squares
Given a positive integer \(N\), your task is to determine the smallest positive integer \(k\) such that the sum of the squares of the first \(k\) positive integers is greater than or equal to \(N\). The sum of squares is defined by the formula: $$S(k)=1^2+2^2+\cdots+k^2=\frac{k(k+1)(2k+1)}{6}.$$
For example, if \(N=5\), then \(k=2\) is the answer because \(1^2+2^2=1+4=5\), which meets the condition \(S(2)\geq5\). Test your program against multiple test cases to ensure correctness and efficiency.
inputFormat
The input consists of a single line containing one integer (N) ((1 \leq N \leq 10^{12})), representing the threshold value for the sum of squares.
outputFormat
Output a single integer (k), which is the minimum number of terms required such that the sum of the squares of the first (k) positive integers is greater than or equal to (N).## sample
1
1