codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1001H.md (1039B)


      1 Source: https://codeforces.com/problemset/problem/1001/H
      2 
      3 H. Oracle for f(x) = parity of the number of 1s in x
      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 Implement a quantum oracle on *N* qubits which implements the following function: ![](https://espresso.codeforces.com/601fd91df91c2fbae106d1ddc30f35b042b484e0.png), i.e., the value of the function is 1 if *x* has odd number of 1s, and 0 otherwise.
     22 
     23 Input
     24 
     25 You have to implement an operation which takes the following inputs:
     26 
     27 * an array of qubits *x* (input register),
     28 * a qubit *y* (output qubit).
     29 
     30 The operation doesn't have an output; the "output" of your solution is the state in which it left the qubits.
     31 
     32 Your code should have the following signature:
     33 
     34 ```
     35 namespace Solution {  
     36     open Microsoft.Quantum.Primitive;  
     37     open Microsoft.Quantum.Canon;  
     38   
     39     operation Solve (x : Qubit[], y : Qubit) : ()  
     40     {  
     41         body  
     42         {  
     43             // your code here  
     44         }  
     45     }  
     46 }
     47 ```