No.1213 sio
タグ : / 解いたユーザー数 29
作問者 :
simasima_71
/ テスター :
Rho
Problem Statement
Siosio loves S-tetrominoes, I-tetrominoes, and O-tetrominoes.
For tetrominoes, please refer to this Wikipedia page.
Siosio places as many of these three types of tetrominoes as possible into a grid with $N$ rows and $M$ columns so that the number of leftover cells is minimized. (Rotation and reflection are allowed.)
However, I-tetrominoes are expensive, so he does not want to use many of them.
Output the minimum possible number of I-tetrominoes that Siosio uses.
Input
$N\ M$
All inputs are integers.
$1 \le N, M \le 100000000=10^8$
Output
Output the minimum number of I-tetrominoes.
Print a newline at the end.
Sample
Sample 1
Input
4 4
Output
0
A $4 \times 4$ grid can hold at most 4 tetrominoes, placed like this.
AABB AABB CCDD CCDDThere is no need to use I-tetrominoes, so output $0$.
Sample 2
Input
1 11
Output
2
At most $2$ tetrominoes fit, as shown here.
.AAAA.BBBB.There is no choice but to use $2$ I-tetrominoes.
Sample 3
Input
3 3
Output
0
At most $1$ tetromino fits.
If you place 1 S-tetromino, you do not need to use any I-tetrominoes.
Sample 4
Input
1 1
Output
0
No tetromino fits in the first place.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。