C4: Modular Arithmetic III

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 400

Problem Statement

You are given an integer nn and two positive integers aa and LL that are coprime.

Implement an oracle OO satisfying the following transition on a quantum circuit qc\mathrm{qc} with 2n+12n + 1 qubits.

For arbitrary integer xx satisfying 0x<L0 \leq x < L, the oracle OO satisfies

x2n+1Oax mod L2n+1\ket{x}_{2n + 1} \xrightarrow{O} \ket{ax \ \text{mod} \ L}_{2n + 1}

Constraints

  • 1n51 \leq n \leq 5
  • 1a<L2n1 \leq a < L \leq 2^n
  • 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, QuantumRegister
 
 
def solve(n: int, a: int, L: int) -> QuantumCircuit:
    x, y = QuantumRegister(n), QuantumRegister(n + 1)
    qc = QuantumCircuit(x, y)
    # Write your code here:
 
    return qc

Please sign in to submit your answer.