An exact approach to the dynamics of locally-resonant beams