A5: Minus One Oracle

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 300

Problem Statement

You are given an integer nn.

For any integer xx satisfying 0x<2n0 \leq x < 2^n, implement the following operation on a quantum circuit qc\mathrm{qc} with nn qubits.

xqc(x1)mod2n\begin{equation} \ket{x} \xrightarrow{\mathrm{qc}} \ket{(x-1) \bmod {2^n}} \nonumber \end{equation}

Note that we define 1mod2n=2n1-1 \bmod {2^n} = 2^n - 1.

Constraints

  • 2n102 \leq n \leq 10
  • The circuit depth must not exceed 1010.
  • Global phase is ignored in judge.
  • Integers must be encoded by little-endian.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Hints

Open
  • You can utilize the inverse operation of xqc(x+1)mod2n\ket{x} \xrightarrow{\mathrm{qc}} \ket{(x+1) \bmod {2^n}}.

Please sign in to submit your answer.