A product puzzle

This is from a math contest. I have solved it, but I'm posting it on here because I think that it would be a good challange problem for precalculus courses. Also, it's kind of fun.

Write the polynomial $\prod_{n=1}^{1996}(1+nx^{3^n})$=$\sum_{n=0}^m a_nx^{k_n}$, where the $k_n$ are in increasing order, and the $a_n$ are nonzero. Find the coefficent $a_{1996}$.

-
Did you mean $k_n$? – copper.hat Jul 6 '12 at 18:40
Never mind. I mean $a_n$ – Chris Dugale Jul 6 '12 at 18:46
@ChrisDugale $k_n$ instead of $k_i$ in the exponent. Also, you should specify that $a_n \ne 0$. I would say the question is more satisfying if you ask for both $k_{1996}$ and $a_{1996}$, else parts of the LHS go unused. – Erick Wong Jul 6 '12 at 18:51
You're right, I should have specified nonzero $a_n$. – Chris Dugale Jul 6 '12 at 18:59
Hint: If you write $k_n$ in base $3$, then it has the same digits as if you wrote $n$ is base $2$. – Thomas Andrews Jul 6 '12 at 19:09