P16274 [Lanqiao Cup 2026 NOI Qualifier C] QR Code Storage

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 \times m$ matrix, consisting of $n$ rows and $m$ 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 $1$ binary bit (bit) to record: $0$ means white, and $1$ 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 $32$ (unit: bit). Therefore, when writing into memory, each row must be aligned to $32\ \text{bit}$. Specifically, each row of the QR code contains $m$ modules, corresponding to $m$ valid data bits: - If $m$ is not a multiple of $32$, pad this row by appending several $0$ at the end, so that the number of bits occupied by this row in memory becomes the smallest multiple of $32$ that is not less than $m$; - If $m$ is exactly a multiple of $32$, no padding is needed. The padded $0$ 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\ \text{Byte} = 8\ \text{bit}$.)

Input Format

The input consists of one line containing two integers $n$ and $m$, 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.

Explanation/Hint

### Sample Explanation **Sample 1**: Each row has $10$ modules. $10$ is not a multiple of $32$, so you need to pad $22$ zeros to make it $32$ bits. Two rows have $64$ bits in total, i.e., $8$ bytes. **Sample 2**: Each row has $40$ modules. $40$ is not a multiple of $32$, and the nearest multiple is $64$, so you need to pad $24$ zeros. Two rows have $128$ bits in total, i.e., $16$ bytes. ### Constraints For $40\%$ of the testdata, $1 \leq n, m \leq 1000$. For all testdata, $1 \leq n, m \leq 10^9$. Translated by ChatGPT 5