#P16274. [蓝桥杯 2026 省 C] 二维码存储

[蓝桥杯 2026 省 C] 二维码存储

Problem Description

A printer produced a QR code, and Xiaolan is going to store its data in the memory of an embedded device.

This QR code is an n×mn \times m matrix, consisting of nn rows and mm columns of black-and-white modules.

The data is stored contiguously in memory in a “row-major” order: store the first row, then the second row, and so on. Each module only needs 11 binary bit (bit) to record: 00 means white, and 11 means black.

However, the hardware limitations of this embedded device are very strict:

  • The space occupied by each row of data in memory must be an integer multiple of 3232 (unit: bit).

Therefore, when writing into memory, each row must be aligned to 32 bit32\ \text{bit}. Specifically, each row of the QR code contains mm modules, corresponding to mm valid data bits:

  • If mm is not a multiple of 3232, pad this row by appending several 00 at the end, so that the number of bits occupied by this row in memory becomes the smallest multiple of 3232 that is not less than mm;
  • If mm is exactly a multiple of 3232, no padding is needed.

The padded 00 bits are only used as padding for this row and are counted in the space occupied by this row. The next row cannot use these padding bits.

Now, Xiaolan wants to know: to store this complete QR code, what is the minimum number of bytes (Byte) of memory he needs to request from the system? (Note: 1 Byte=8 bit1\ \text{Byte} = 8\ \text{bit}.)

Input Format

The input consists of one line containing two integers nn and mm, representing the number of rows of the QR code and the number of modules in each row, respectively.

Output Format

Output one integer, representing the minimum number of bytes required to store this QR code.

2 10
8
2 40
16

Hint

Sample Explanation

Sample 1: Each row has 1010 modules. 1010 is not a multiple of 3232, so you need to pad 2222 zeros to make it 3232 bits. Two rows have 6464 bits in total, i.e., 88 bytes.

Sample 2: Each row has 4040 modules. 4040 is not a multiple of 3232, and the nearest multiple is 6464, so you need to pad 2424 zeros. Two rows have 128128 bits in total, i.e., 1616 bytes.

Constraints

For 40%40\% of the testdata, 1≤n,m≤10001 \leq n, m \leq 1000.
For all testdata, 1≤n,m≤1091 \leq n, m \leq 10^9.

Translated by ChatGPT 5