I want to find longest sequence of distinct squares that $\alpha\_{\_1}$ + ... + $\alpha\_{\_n}$ is given number.
In particular I want to find largest square in that sequence.


I've tried use Lagrange's four-square theorem, and then Fermat's theorem on biggest squares, but it it's not correct solution.


Please help me.
Sorry for my poor English. :)



Longest sequence of sum of distinct squares
I'll assume you're talking about squares of positive integers (of course you can always include $0$ if you prefer, increasing the length by $1$). 
Let $F(n)$ be the 
length of the longest sequence representing $n$, or $-\infty$ if there is no such sequence. Finding $F(n)$ can be viewed as a 
type of knapsack problem: if $k = \lfloor \sqrt{n}\rfloor$,


maximize $\sum\_{j=1}^k x\_j$ 


subject to
$\sum\_{j=1}^k j^2 x\_j = n$


all $x\_j \in \{0,1\}$


We therefore have a pseudo-polynomial dynamic programming algorithm. 
Let 
$A(n, j)$ be the length of the longest sequence representing $n$ using 
distinct squares of integers $\le j$, or $0$ if there is no such sequence.
Then $F(n) = A(n, \lfloor \sqrt{n}\rfloor)$, and
$$ \eqalign{A(0, j) &= 0 \cr
A(n,j) &= -\infty \ \text{if}\ n > \sum\_{k=1}^j k^2\cr
A(n,j) &= A(n, j-1) \ \text{if}\ n < j^2\cr
A(n, j) &= \max(A(n,j-1), 1 + A(n-j^2, j-1))\ \text{otherwise}}$$


