C++20 sections · 1024 units
Open in Course

Domino piling - Algorithm

Breaking down the solution

Here's your approach:

1.1. Read the board dimensions MM and NN.

2.2. Calculate the total area:

4.4. Output the result. That's the entire algorithm. No edge cases to check, no special handling needed. The math works for all valid inputs, whether the area is even or odd. You can write a helper function to make this clearer. A function like

Each step should be clear and testable. Before coding, trace through with a small example to verify the logic. Think about edge cases: empty input, single element, maximum values. Make sure your algorithm handles them correctly.