Help solve the Olympiad problem in computer science about cells on a chessboard

Condition: The chessboard consists of n×m cells, colored black and white in a checkerboard pattern. In this case, the cell in the lower left corner of the board is painted black. Determine how many black cells there are on the board. The program receives the natural numbers n and m as input. The program should output the answer to the problem. For example: 3 4 Output: 6 I tried different boards on paper: it always turned out half black and white

n, m = int(input()), int(input())
print(n * m / 2)

This code does not accept.

Author: ProgrammingAtKorhal, 2020-05-12

2 answers

n = int(input())
m = int(input())
print((n * m + 1) // 2)

Thanks for the comments, with odd * odd I somehow did not check

 4
Author: ProgrammingAtKorhal, 2020-05-12 14:29:19

In one case, the number of white and black will be different-when n and m are odd. For all other cases, a simple division by 2 will give the desired answer.

3 x 3 = 9

x 0 x
0 x 0
x 0 x

5 - черных, 4 белых

That is, the answer to your problem is to round it up after dividing by 2.

 1
Author: Yugofx, 2020-05-12 14:30:38