Infer number of terms in sum, given the value of the sum In preparation for a math contest my little brother's teacher gave him a nice little book full of interesting little math exercises. And whenever my brother got stuck, he asks me for help and we usually figure something out -- mostly it's a neat and painless solution for this book is made for 10/9/8-graders.
But today my brother showed me the following task, and told me that he is really stuck:

You have got $335$ different, positive integers whose sum adds up to
  $100000$.
Q: What is the smallest and highest required number of odd summands?

Any kind of help or advice will be really appreciated.
 A: If we have $n$ even and $m$ odd numbers, then the sum of the even numbers is at least $2 + 4 + 6 + \ldots + 2n = n \times \frac{2n + 2}{2} = n^2 + n$, the sum of the odd numbers is at least $1 + 3 + ... + (2m - 1) = m \times \frac{2m - 1 + 1}{2} = m^2$. 
If we choose $n = 317$, the sum is at least $101130$. If we choose $n = 315$, $m = 20$, the sum is at least $99940$. We can get a sum of $100000$ by taking the $317$ smallest even and the $20$ smallest odd numbers, then increasing the largest of these numbers by $60$. At least $20$ odd summands are needed. 
If we take $n = 19$ and $m = 316$, the sum is at least $100236$. If we choose $n = 21$ and $m = 314$, the sum is at least $99058$. We can get a sum of $100000$ by taking the $21$ smallest even and the $314$ smallest odd numbers, then increasing the largest of these numbers by $942$. At most $314$ odd summands are possible. 
A: The sum of $n$ odd summnds is at least $1+3+5+\ldots +(2n-1)=n^2$ and can be increases in steps of $2$ from that, i.e. to $n^2+2a$ for some $a\in \mathbb N_0$.
The sum of $m$ even numbers is at least $2+4+6+\ldots +2m = m(m+1)$ and can also be increased in steps of $2$, i.e. to $m(m+1)+2b$ for some $b\in\mathbb N_0$.
With a total of $n+m=335$ summands, we can thus obtain any sum $$n^2+(335-n)(336-n)+2(a+b)$$
that is any number $S$ with $$S\ge 2n^2-671n+112560\qquad\text{and}\qquad S\equiv n\pmod 2.$$
For $S=100000$, we thus need $n=2k$ even and $$8k^2-1342k+112560\le 1000000. $$
With the quadratic formula you should find $9.949\ldots<k<157.8007\ldots$, i.e. the minimal $n$ is $n=20$, the maximal is $n=314$.
