B4: Left and Right Aligned

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 400

Problem Statement

You are given integers nn, ss and tt.

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

  1. For arbitrary integer kk satisfying sk<2ns \leq k < 2^n, the oracle OO satisfies
kn+1Oksn+1\ket{k}_{n+1} \xrightarrow{O} \ket{k - s}_{n+1}
  1. For arbitrary integer kk satisfying 2nk<t2^n \leq k < t, the oracle OO satisfies
kn+1Ok+2n+1tn+1\ket{k}_{n+1} \xrightarrow{O} \ket{k + 2^{n+1} - t}_{n+1}

Constraints

  • 1n101 \leq n \leq 10
  • 0s<2n<t<2n+10 \leq s < 2^n < t < 2^{n+1}
  • 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, s: int, t: int) -> QuantumCircuit:
    qc = QuantumCircuit(n + 1)
    # Write your code here:
 
    return qc

Hints

Open
  • You can consider the way to apply the solution of problem B3.

Please sign in to submit your answer.