The following languages are only available languages for the problems from the contest

Microsoft Q# Coding Contest - Summer 2020 - Warmup:

- Microsoft Q#

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
B2. Decrement

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputImplement a unitary operation on a register of $$$N$$$ qubits that decrements the number written in the register modulo $$$2^N$$$.

Your operation should take a register of type LittleEndian - 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). The "output" of your solution is the state in which it left the input qubits.

For example, if the qubits passed to your operation are in the state $$$\frac{1}{\sqrt{2}}(|00\rangle + |01\rangle) = \frac{1}{\sqrt{2}}(|0\rangle + |2\rangle)$$$, they should be transformed to the state $$$\frac{1}{\sqrt{2}}(|(0-1) \mod 2^2\rangle + |(2-1) \mod 2^2\rangle) = \frac{1}{\sqrt{2}}(|3\rangle + |1\rangle) = \frac{1}{\sqrt{2}}(|11\rangle + |10\rangle)$$$.

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 (register : LittleEndian) : Unit is Adj+Ctl {

// your code here

}

}

Your code is not allowed to use measurements or arbitrary rotation gates (so, for example, using the library operation IncrementByInteger will cause runtime error). This operation can be implemented using just the X gate and its controlled variants.

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/21/2021 09:05:22 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|