#B4061. Binary Bit Operations

    ID: 11718 Type: Default 1000ms 256MiB

Binary Bit Operations

Binary Bit Operations

You are given a positive integer \(a\) and an integer \(b\). We define the binary \(b\)th bit of \(a\) as the bit in the binary representation of \(a\) when read from right to left, with the rightmost bit being the 0th bit.

For example, if \(a=11\), its binary representation is shown below:

Bit Position 4 3 2 1 0
Bit Value 0 1 0 1 1

In this example, the binary 2nd bit of \(11\) is \(0\).

Your task is to compute and output the following six results (each on a separate line):

  1. \(a \times 2^b\).
  2. \(a \div 2^b\) (using floor division).
  3. The \(b\)th bit of \(a\) in its binary representation.
  4. The decimal number obtained by setting the \(b\)th bit of \(a\) to \(0\).
  5. The decimal number obtained by setting the \(b\)th bit of \(a\) to \(1\).
  6. The decimal number obtained by toggling (inverting) the \(b\)th bit of \(a\).

Note that in the binary representation, bits are counted starting from 0 (rightmost bit).

All formulas are represented in \(\LaTeX\) format.

inputFormat

The input consists of a single line containing two space-separated integers \(a\) and \(b\), where \(a\) is a positive integer and \(b\) is a non-negative integer.

outputFormat

Output 6 lines. Each line should contain one integer result corresponding to the following:

  • \(a \times 2^b\).
  • \(\lfloor a \div 2^b \rfloor\) (floor division).
  • The \(b\)th bit of \(a\).
  • The decimal result after setting the \(b\)th bit of \(a\) to \(0\).
  • The decimal result after setting the \(b\)th bit of \(a\) to \(1\).
  • The decimal result after toggling the \(b\)th bit of \(a\).

sample

11 2
44

2 0 11 11 15

</p>