P29692 [洛谷] [COCI2011-2012#3] POGODAK
入门
题目描述

Problem Background

Mirko dislikes Latin homework, so he made a bet with Slavko. The loser will do both of their homework for the entire month. Mirko wants to win, so he devised this problem for the bet.

Problem Description

On his desk, he found a cube as shown in the figure.

In this cube, the sum of the numbers on opposite faces is equal to 7. This means, 6 is opposite 1, 5 is opposite 2, and 4 is opposite 3. Mirko placed the cube at the top-left corner of an \( r \times c \) matrix, initially with 1 on the top and 3 on the right side. Mirko then repeatedly performs the following actions:

  1. Roll the cube to the right until it reaches the last column.
  2. Roll the cube down to the next row.
  3. Roll the cube to the left until it reaches the first column.
  4. Roll the cube down to the next row, as in step 2.

Mirko keeps repeating these steps until the cube can no longer roll. When the cube reaches a cell, Mirko writes down the number on the top of the cube in that cell. Finally, he sums up all the numbers he wrote down. Mirko bet Slavko that he can accurately calculate this sum without error. Help Slavko calculate this sum to verify Mirko's answer.

Input Format

The input consists of a single line with two integers \( r \) and \( c \), representing the number of rows and columns of the matrix, respectively.

Output Format

The output should be a single integer, representing the sum of all the numbers filled in the matrix.

Sample Input and Output

Sample Input #1

3 2

Sample Output #1

19

Sample Input #2

3 4

Sample Output #2

42

Sample Input #3

737 296

Sample Output #3

763532

Notes

[Sample 1 Explanation]

For sample 1, the numbers filled in the matrix are as follows:

$1$ $4$
$1$ $5$
$3$ $5$

Thus, the final sum is \( 1 + 4 + 1 + 5 + 3 + 5 = 19 \).

[Data Range]

For 50% of the test cases, \( r, c \leq 100 \).
For all test cases, \( 1 \leq r, c \leq 10^5 \).

[Problem Source]

This problem is from COCI 2011-2012 CONTEST 3 T3 POGODAK, configured with the original data. Full score is 100 points.

Translated and provided by Eason_AC.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2
样例输出
19