#P7744. Cube Rolling Sum
Cube Rolling Sum
Cube Rolling Sum
On his desk, Mirko found a cube as shown in the figure below.
In this cube, the numbers on two opposite faces always add up to \(7\). This means that \(6\) is opposite to \(1\), \(5\) is opposite to \(2\), and \(4\) is opposite to \(3\). Initially, the cube is placed in the top-left cell of an \(r \times c\) grid with the top face showing \(1\) and the right face showing \(3\). (Thus, by deduction, the left face is \(4\), the front face is \(2\), and the back face is \(5\).)
Mirko then repeats the following steps until the cube can no longer be moved:
- Roll the cube to the right until it reaches the last column.
- Roll it down to the next row.
- Roll the cube to the left until it reaches the first column.
- Roll it down to the next row.
Each time the cube lands on a cell, he writes down the number on its top face. Finally, he sums all these numbers. Your task is to help Slavko calculate the total sum written down by Mirko.
inputFormat
The input consists of a single line containing two integers \(r\) and \(c\) (\(1 \le r, c \le 1000\)), which denote the number of rows and columns of the grid.
outputFormat
Output a single integer: the total sum of the numbers written down on the grid.
sample
2 2
11