1002A2.md (2185B)
1 Source: https://codeforces.com/problemset/problem/1002/A2 2 3 A2. Generate superposition of zero state and a basis state 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given *N* qubits (1 ≤ *N* ≤ 8) in zero state . You are also given a bitstring *bits* which describes a non-zero basis state on *N* qubits . 22 23 Your task is to generate a state which is an equal superposition of  and the given basis state: 24 25  26 27 You have to implement an operation which takes the following inputs: 28 29 * an array of qubits *qs*, 30 * an arrays of boolean values *bits* representing the basis state . This array will have the same length as the array of qubits. The first element of this array *bits*[0] will be true. 31 32 The operation doesn't have an output; its "output" is the state in which it leaves the qubits. 33 34 An array of boolean values represents a basis state as follows: the *i*-th element of the array is true if the *i*-th qubit is in state , and false if it is in state . For example, array [true; false] describes 2-qubit state , and in this case the resulting state should be . 35 36 Your code should have the following signature: 37 38 ``` 39 namespace Solution { 40 open Microsoft.Quantum.Primitive; 41 open Microsoft.Quantum.Canon; 42 43 operation Solve (qs : Qubit[], bits : Bool[]) : () 44 { 45 body 46 { 47 // your code here 48 } 49 } 50 } 51 ```