A unifying approach to solve a class of rank-three programs involving linear and quadratic functions