Connection Status:
Competition Arena > PaintingCells
Rookie SRM 4 · 2021-04-09 · by ltaravilse · Brute Force, Simple Math, Simple Search, Iteration
Class Name: PaintingCells
Return Type: int
Method Name: paint
Arg Types: (int, int)
Problem Statement

Problem Statement

You're given the number of rows and columns of a board. You want to paint it black and white like a chess board. You know that the first cell of the first row is white. Calculate and return the number of white cells in the board after you paint it.

Constraints

  • rows and columns will be between 1 and 100 inclusive.
Examples
0)
1
1
Returns: 1

The only cell in the board is white

1)
3
2
Returns: 3

There are three white cells and three black cells as follows: WB BW WB

2)
7
13
Returns: 46
3)
10
10
Returns: 50
4)
20
20
Returns: 200

Submissions are judged against all 27 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class PaintingCells with a public method int paint(int rows, int columns) · 27 test cases · 2 s / 256 MB per case

Submitting as anonymous