Minimal number of square

Input N - number. 0 <N < 90000.
Your task to find minimal number of square which together give the number N.


Example:
1) Input: 4. Answer: 1.
So, 4 = 2*2.
2) Input: 10. Answer: 2. 
10 = 3*3 + 1*1;
3) Input 14. Answer: 3.
14 = 3*3+2*2+1*1.

IN

344

OUT

3

IN

4

OUT

1

IN

10

OUT

2

IN

12

OUT

3

IN

7

OUT

4

IN

58509

OUT

3

IN

89968

OUT

4


Leave a comment

Parsed as Markdown

Login to leave a comment