Solution (source code)

= Solution

With an origin at an inversion center, the <structure factors> are real, so their phases are either $0$ or $\pi$. Defining $S(h)=\operatorname{sgn}F(h)$ gives
$$
\rho(x)=F(0)+2\sum_{h=1}^\infty S(h)|F(h)|\cos(2\pi hx).
$$
Centrosymmetry converts the phase problem into a sign problem; it does not imply that every <structure factor> is positive.