A5: Minus Oracle

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 400

Problem Statement

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

The oracle OO acts on basis states kn\ket{k}_n, where 0k<2n0 \leq k < 2^n, as follows:

knOk mod 2nn.\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 0x<2n0 \leq x < 2^n and k+xk + x is divisible by 2n2^n.

Constraints

  • 1n101 \leq n \leq 10
  • The circuit depth must not exceed 3030.
  • Integers must be encoded by little-endian.
  • Global phase is ignored in judge.
  • 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

Please sign in to submit your answer.