#P7744. [COCI 2011/2012 #3] POGODAK
[COCI 2011/2012 #3] POGODAK
Description
On his desk, he found a cube, as shown in the picture.

On this cube, the sum of the numbers on two opposite faces is . This means that is opposite , is opposite , and is opposite . Mirko places the cube at the top-left cell of an matrix. Initially, the cube is oriented with on the top face and on the right face. Mirko then repeatedly performs the following actions in order:
- 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.
- As in step 2, roll it down to the next row.
Mirko keeps repeating these steps until the cube can no longer be rolled. Each time the cube arrives at a cell, Mirko writes down the number on the top face in that cell. In the end, he adds up all the numbers he wrote. Mirko bet Slavko that he could calculate this sum without any mistakes. Help Slavko compute this sum to verify Mirko's answer.
Input Format
The input consists of a single line with two integers , representing the number of rows and columns of the matrix.
Output Format
Output a single line with one integer, the sum of all numbers filled in the final matrix.
3 2
19
3 4
42
737 296
763532
Hint
Sample 1 Explanation
For sample , the numbers filled in the final matrix are as follows:
Therefore, the final sum is .
Constraints
For of the testdata, .
For all testdata, .
Source
This problem is from COCI 2011-2012 CONTEST 3 T3 POGODAK, using the original testdata settings, worth points.
Translated and整理 (zhengli) provided by Eason_AC.
Translated by ChatGPT 5
京公网安备 11011102002149号