E1. Power of quantum Fourier transform
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Implement an operation that is equivalent to the operation QFT$$$^P$$$, where QFT is the quantum Fourier transform.

Your operation should take the following inputs:

  • an integer $$$P$$$ ($$$2 \le P \le 2.1\cdot 10^6$$$).
  • a register of type LittleEndian - a wrapper type for an array of qubits that encodes an unsigned integer in little-endian format, with the least significant bit written first (corresponding to the array element with index 0). (If you need to, you can convert it to an array type using unwrap operator: let qubitArray = inputRegister!;)

The "output" of your solution is the state in which it left the input qubits.

Your code should have the following signature (note that your operation should have Adjoint and Controlled variants defined for it; is Adj+Ctl in the operation signature will generate them automatically based on your code):

namespace Solution {
open Microsoft.Quantum.Arithmetic;
open Microsoft.Quantum.Intrinsic;

operation Solve (p : Int, inputRegister : LittleEndian) : Unit is Adj+Ctl {
// your code here
}
}

You can learn more about QFT in this kata. You are allowed to take advantage of library operations, including QFTLE which implements the necessary transform in the first power.