-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsquare_granites.py
68 lines (62 loc) · 1.48 KB
/
square_granites.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -----------------------------------------------
# Author : Mohit Chaudhari
# Created Date : 08/07/21
# -----------------------------------------------
# Square granites
# Problem Description
#
# A city is of rectangular shape with the size A * B meters. On the occasion of the city's anniversary, a decision was taken to pave the city with square granite flagstones. Each flagstone is of the size C * C. What is the least number of flagstones needed to pave the city?
#
# NOTE: It's allowed to cover the surface larger than the city, but the city has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the city.
#
#
#
# Problem Constraints
# 1 <= A <= 109
#
# 1 <= B <= 109
#
# 1 <= C <= 109
#
#
#
# Input Format
# First argument is an integer A as per the question.
#
# Second argument is an integer B as per the question.
#
# Third argument is an integer C as per the question.
#
#
#
# Output Format
# Return an integer showing least number of flagstones needed.
#
#
#
# Example Input
# Input 1:
#
# A=6, B=6, C=4
#
#
# Example Output
# Output 1:
#
# 4
#
#
# Example Explanation
# Explanation 1:
#
# If we use 4 flagstones(2 rows and 2 columns) then it will cover the whole city.
import math
class Solution:
# @param A : integer
# @param B : integer
# @param C : integer
# @return an integer
def solve(self, A, B, C):
return math.ceil(A / C) * math.ceil(B / C)
s = Solution()
print(s.solve(6, 6, 4))