oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

cubecutting Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

cubecutting.html

Problem Description

Rar the cat has a large ice cube of dimensions H by W by D cm3. It is very inconvenient to carry a large cube. Hence, Rar the Cat would like to cut the large ice cube into H * W * D ice cubes of unit dimensions (1 by 1 by 1 cm3).

However, Rar the Cat wants to know that is the minimum number of cuts required to cut up the large ice cube into ice cubes of unit dimensions. Each cut is defined as taking a piece of ice cube of any size and cutting it into 2 ice cubes of any size. The cuts can be in any direction you wish but only 1 ice cube can be cut at a time.

Input

The first line of input will contain 3 integers, H followed by W and then D.

Output

Output a single integer, the minimum number of cuts required to cut up the large ice cube.

Limits

Subtask 1 (33%): 1 ≤ H ≤ 1000, W = 1, D = 1

Subtask 2 (40%): 1 ≤ H, W, D ≤ 1000

Subtask 3 (27%): 1 ≤ H, W, D ≤ 106

Sample Testcase 1

Input

1 1 1

Output

0

Sample Testcase 2

Input

1 2 2

Output

3

Sample Testcase 3

Input

10 1 1

Output

9

Tags

Math

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
13351s256MBMinimum
240201s256MBMinimum
327201s256MBMinimum
4031s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o cubecutting -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.