QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#9628. Dice

Estadísticas

In the top-left cell of an $n \times m$ grid, there is a die with side length equal to the side length of the grid cells. Initially, the die has $1$ on the top face, $2$ on the front face, $3$ on the right face, and the face opposite to $i$ is $7 - i$, as shown in the figure below.

Initial state of the die

You can perform any number of operations, where each operation is one of the following two types:

  • If the current cell the die is on does not have a number, write the number on the bottom face of the die onto this cell.
  • Choose one of the four directions (up, down, left, right) and roll the die once in that direction: select the edge of the die corresponding to the chosen direction and rotate the die ninety degrees along this edge. The figure below shows the result of rolling the die to the right once from the initial state. You cannot roll the die outside the grid.

Result of rolling the die to the right once

Note: You can choose not to write the number on the bottom face of the die onto a cell when the die passes through a cell that does not have a number.

You want to maximize the sum of the numbers written on all cells of the grid that have been written on.

Input

The input is read from standard input. The input consists of a single line containing two integers $n, m$ ($2 \le n, m \le 10^3$), representing the length and width of the grid.

Output

Output to standard output. Output a single integer representing the maximum possible sum of the numbers on all cells that have been written on after performing any number of operations.

Examples

Input 1

2 2

Output 1

24

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.