Q factor of a resonator by the finite-difference time-domain method incorporating perturbation techniques