In this paper, let q be an odd prime power. Based on new constacyclic codes which contain their Hermitian duals and Hermitian construction, we construct some classes of quantum MDS codes and quantum codes. When q ≡ 1 mod 4 , x and y are a divisor of q - 1 and q + 1 , respectively, we can construct a class of new quantum codes of length n = 2 x y q 2 m - 1 q 2 - 1 for odd x , y , m ≥ 3 . These codes have larger dimensions than existing codes. In addition, for q with the form 2 a m ± (x 2 + y 2) a - 1 and odd x, y, a with g c d (x , y) = 1 , we get some quantum MDS codes of length n = q 2 + 1 a . [ABSTRACT FROM AUTHOR]