C5: Modular Arithmetic IV

Time Limit: 10 sec

Memory Limit: 512 MiB

Score: 600

Problem Statement

You are given integers nn and mm, and two positive integers aa and LL that are coprime.

Implement an operation that prepares a superposition state A\ket{A} from the zero state on a quantum circuit qc\mathrm{qc} with n+2m+1n + 2m + 1 qubits.

The superposition state A\ket{A} is defined by

An+2m+1=12nk=02n1knak mod L2m+1.\ket{A}_{n+2m+1} = \frac{1}{\sqrt{2^n}} \sum_{k=0}^{2^n-1} \ket{k}_n \ket{a^k \ \text{mod} \ L}_{2m+1}.

Constraints

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

Please sign in to submit your answer.