codeforces-scrape

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

1002D3.md (1295B)


      1 Source: https://codeforces.com/problemset/problem/1002/D3
      2 
      3 D3. Oracle for majority function
      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 3 qubits which implements a majority function. Majority function on 3-bit vectors is defined as follows: ![](https://espresso.codeforces.com/f1b82a29ad1451ba70f5de92d7fdba87148a674f.png) if vector ![](https://espresso.codeforces.com/f8914399eadbd8be3c3196100658870e03c61fee.png) has two or three 1s, and 0 if it has zero or one 1s.
     22 
     23 For an explanation on how this type of quantum oracles works, see [Introduction to quantum oracles](https://codeforces.com/blog/entry/60319).
     24 
     25 You have to implement an operation which takes the following inputs:
     26 
     27 * an array of 3 qubits *x* in arbitrary state (input register),
     28 * a qubit *y* in arbitrary state (output qubit).
     29 
     30 The operation doesn't have an output; its "output" is the state in which it leaves 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 ```