Let $a$ be a real number. The equation $a(\cos x+\cos3x)=\sin4x$ has more than three solutions in the interval $(0,\pi)$ if and only if $a$ lies in $(p,q)\cup(q,r)$ for some real numbers $p<q<r$. What is $p+q+r$?
Use sum-to-product: $\cos x+\cos3x=2\cos2x\cos x$ and $\sin4x=2\sin2x\cos2x=4\sin x\cos x\cos2x$. The equation becomes $2\cos x\cos2x\,(a-2\sin x)=0$.
In $(0,\pi)$, $\cos x=0$ gives $x=\frac\pi2$ and $\cos2x=0$ gives $x=\frac\pi4,\frac{3\pi}4$: three solutions for every $a$.
The factor $a-2\sin x=0$ gives $\sin x=\frac a2$, which has two solutions $x$ and $\pi-x$ in $(0,\pi)$ when $0<\frac a2<1$, and none when $a\le0$ or $a>2$ (at $a=2$ it gives only $x=\frac\pi2$, already counted).
These two are new unless they coincide with $\frac\pi4,\frac{3\pi}4$, i.e. $\frac a2=\frac{\sqrt2}2$, $a=\sqrt2$. So there are more than three solutions exactly for $a\in(0,\sqrt2)\cup(\sqrt2,2)$.