A5: Minus Oracle

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 400 points

Problem Statement

Given an integer nn, implement an nn-qubit oracle OO on a quantum circuit qc\mathrm{qc}.

For any integer kk satisfying 0≤k<2n0 \leq k < 2^n, the required transformation is as follows:

∣k⟩n→O∣−k mod 2n⟩n\ket{k}_n \xrightarrow{O} \ket{- k \ \text{mod} \ 2^n}_n

Here, −k mod 2n- k \ \text{mod} \ 2^n denotes the unique integer xx such that 0≤x<2n0 \leq x < 2^n and k+xk + x is divisible by 2n2^n.

Constraints

from qiskit import QuantumCircuit
 
 
def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Hints

Open

Please sign in to submit your answer.