문제
n*m의 사각형을 a*a 블록으로 채우려고 할 때, 총 몇개의 블럭이 필요한가.
풀이
직사각형의 각 변을 a로 나눠 ceil()로 올림해서 서로 곱하면 블럭의 최소 개수가 나온다.
코드
n,m,a=map(int, input().split())
from math import ceil
print(ceil(n/a) * ceil(m/a))
'Codeforces > Python' 카테고리의 다른 글
[Codeforces] 50A - Domino piling (Python) (1) | 2025.05.19 |
---|---|
[Codeforces] 158A - Next Round (Python) (0) | 2025.05.16 |
[Codeforces] 282A - BIt++ (Python) (0) | 2025.05.13 |
[Codeforces] 231A - Team (Python) (0) | 2025.05.13 |
[Codeforces] 71A - Way Too Long Words (Python) (0) | 2025.05.11 |