Nontrivial solutions of a class of fractional differential equations with p-Laplacian via variational methods