TITLE: Number of ways to divide a stick of integer length $N$
QUESTION [13 upvotes]: Suppose we have a stick of integer length $N$. I'm looking for (preferably closed-form) formula that gives the numbers of ways in which we can divide the stick into 3 parts with distinct integral lengths.
EDIT: Also, every part in any division has unique length which does not appear in any other division of $N$.
EDIT2: Based on coffeemath's answer, just to clarify, I'm interested in maximal number of sums $F(n)$. Given some $N$, count the number of all possible ways to divide stick $N$ into 3 parts such that the length of any part in any valid division is unique number between $1$ an $N$.

REPLY [6 votes]: The array $$\matrix{1&30&16&4&24&31&7&18&13&15&28\cr17&2&32&20&5&14&23&8&29&22&11\cr33&19&3&27&22&6&21&25&9&10&12\cr}$$ uses each integer $1,2,\dots,33$ exactly once; each column sums to $51$ (so we have $11$ ways to divide a stick of length $51$ into three parts); and, as a bonus, each row sums to $187$. There's a calculator that finds such things. 
It has been proved that an $m\times n$ magic rectangle exists provided $m$ and $n$ have the same parity and exceed $1$, with the sole exception of $m=n=2$. Taking $m=3$, this gives a way of dividing a stick of length $(9n+3)/2$ into three parts in $n$ ways, where $n$ is an arbitrary odd number exceeding $1$. It's pretty clear that stick can't be divided into three parts in more than $n$ ways; if you can do it in $k$ ways, then the numbers used must add up to $k(9n+3)/2$, but they must also add up to at least $3k(3k+1)/2$, and this is easily seen to imply $k\le n$. 
In short, if $N$ is of the form $(9n+3)/2$, $n$ odd, then the number of ways is $(2N-3)/9$. 
The magic rectangles theorem has been proven, and constructions given, in many papers. One, which gives references to others, is Thomas R Hagedorn, Magic rectangles revisited, Discrete Mathematics 207 (1999) 65-72. Of course, the construction is a bit of overkill for this problem, as we don't really need a magic rectangle, we just need the columns sums to be equal and don't care about the row sums. Here's a simple construction which just solves the original construction, without giving a magic rectangle: $$\matrix{1&2&3&4&5&6&7&8&9&10&11\cr17&18&19&20&21&22&12&13&14&15&16\cr33&31&29&27&25&23&32&30&28&26&24\cr}$$ The pattern should be clear. 
EDIT: Now, suppose $N$ is not of the form $(9n+3)/2$ with $n$ odd. Let's write $n'=n+1$ and $n''=n+2$, and $${9n+3\over2}\lt N\lt{9n''+3\over2}$$ for some odd $n$. First, we note that $F(N)\ge n$; if $N-(1/2)(9n+3)=k$, then just add $k$ to each entry in the bottom row in the construction above. and you have $n$ ways to divide $N$ into three parts. Second, note that $F(N)\le(2N-3)/9$, by the argument a few paragraphs up about the sum of the numbers involved. So we get 

If $(1/2)(9n+3)\lt N\lt (1/2)(9n'+3)$, then $f(N)=n$; 
If $(1/2)(9n'+3)\le N\lt(1/2)(9n''+3)$, then $f(N)$ is either $n$ or $n+1$. 

In summary, for every $N$, we have a formula for $f(N)$ which is exact in some ranges, and off by at most $1$ in other ranges. I suspect that the $n+1$ is generally correct in the situation where we haven't pinned things down. For example, for $N=20$, we have $$((9)(4)+3)/2\lt N\lt((9)(5)+3)/2$$ with the left inequality barely holding, and we get $f(20)=4$ from $$\matrix{1&2&3&4\cr5&7&8&6\cr14&11&9&10\cr}$$