C5: Modular Arithmetic IV

Time Limit: 10 seconds

Memory Limit: 512 MiB

Score: 600 points

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

∣A⟩n+2m+1=12n∑k=02n−1∣k⟩n∣ak mod L⟩2m+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

  • 1≤n≤51 \leq n \leq 5
  • 1≤m≤51 \leq m \leq 5
  • 1≤a<L≤2m1 \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.