Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2025/iii/paper-324/3/a/ii/solution

Apply Hadamard gates to to prepare
Reversibly compute the efficiently decidable predicate into an ancillary qubit and measure it. The success probability is , and conditioned on success the first register is exactly
Restart after a failed measurement. After attempts, the probability that all attempts fail is below , so the state is prepared with probability at least using a number of gates polynomial in and .

New to topics? Read the docs here!