#K61382. Count Adjacent Tiles

    ID: 31297 Type: Default 1000ms 256MiB

Count Adjacent Tiles

Count Adjacent Tiles

Given a grid with \( R \) rows and \( C \) columns, your task is to calculate the total number of ways to pick two adjacent tiles. Two tiles are considered adjacent if they share a common side. The number of horizontal adjacent pairs can be computed as \( R \times (C - 1) \) and the number of vertical adjacent pairs as \( (R - 1) \times C \). The final answer is the sum of these two numbers.

Example: For a grid of 2 rows and 2 columns, the answer is \( 2 \times (2-1) + (2-1) \times 2 = 2 + 2 = 4 \).

inputFormat

The input consists of two integers \( R \) and \( C \), separated by space, where \( R \) denotes the number of rows and \( C \) denotes the number of columns in the grid.

outputFormat

Output a single integer representing the total number of adjacent tile pairs in the grid.

## sample
2 2
4