Problem Description Link
Algorithm:
Algorithm:
This is a simple problem
to solve this problem you can pre generate the number of minimum terms
for all integer from 1 to 10000 and get input and check from array how
many term needed and print the value.
Process:
For any positive
integer N , N = a1
2 + a2
2 +...+ an
2 that is, any positive integer can be represented as sum of
squares of other numbers.



For example you know minimum term of 1,2,3,4 and based on
this value calculate others 5 to 10000
value term
1
|
2
|
3
|
1
|
2
|
3
|
4
|
2
|
1
|
2
|
1 2 3 4 5 6 7 8 9 10
For 5
S=sqrt(5)=2
Way 22+12=5
so 2 term
And 12+22=5
so 2 term
Min value=2
So