Here is my solution for generic $n$. I'm not sure whether it is correct.
Case 1: $x_i$ is possible to reach the mean value $K/n$.
The problem actually is maximizing $\Pi_{i=1}^nx_i$ subject to $\sum_{i=1}^nx_i=K$. Use Lagrange multiplier: $f(x)=\sum_{i=1}^n \log x_i + \lambda \left( \sum_{i=1}^nx_i-K \right)$ Form $\frac{\partial f}{\partial x_i}=0$ and $\frac{\partial f}{\partial \lambda}=0$, we have $x_i=K/n$ and $\lambda = -n/K$.
Case 2: Some $x_i$ is impossible to reach the mean value $K/n$.
For example, $x_i\le \alpha _i < K/n$ for $i=1,...,q$ and $x_i\ge \beta _i > K/n$ for $i=q+1,...,n$. Now I still use the Lagrange multiplier $\lambda =-n/K$ (right?)and $f(x)=\sum_{i=1}^n \log x_i + \lambda \left( \sum_{i=1}^nx_i-K \right)$ Now $\frac{\partial f}{\partial x_i}=\frac{1}{x_i}-\frac{n}{K}$ For $i=1,...,q$, $\frac{1}{x_i}-\frac{n}{K}>0$, so $f$ is larger when $x_i$ is larger. For $i=q+1,...,n$, $\frac{1}{x_i}-\frac{n}{K}<0$, so $f$ is larger when $x_i$ is smaller.
Now I think I can say $\Pi_{i=1}^nx_i$ is maximized when $x_i$ approaches the mean value as close as possible. However, I am still not clear on some questions.
a) Am I right to use Lagrange multiplier in the Case 2?
b) if $x_i$ are upper or lower bounded by $\alpha _i$ and $\beta _i$, can we say $\Pi_{i=1}^nx_i$ is maximized when these bounded are achieved? When $\sum \alpha _i+\sum \beta _i=K$, I think so.