Quantum Complexity for Discrete Logarithms and Related Problems