Problems > Breaking Chocolate

Breaking Chocolate

Difficulty: 900 2000 ms 128 MB

math

An N×M chocolate bar must be broken into its N·M unit squares; each break splits ONE piece along a line. How many breaks are needed?

Input: one line with two integers N and M.

Output: N·M − 1.

Constraints:

  • 1 ≤ N, M ≤ 109

Sample Tests

Input 1
2 3
Output 1
5
Input 2
1 1
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.