We have a grid with H rows and W columns, where all the squares are initially white. You…
- User
We have a grid with H rows and W columns, where all the squares are initially white.
You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:
- Choose one row, then paint all the squares in that row black.
- Choose one column, then paint all the squares in that column black.
At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
Constraints
- 1 \leq H \leq 100
- 1 \leq W \leq 100
- 1 \leq N \leq H \times W
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
H W N
Output
Print the minimum number of operations needed.
Examples
Input
3 7 10
Output
2
Input
14 12 112
Output
8
Input
2 100 200
Output
2
Assistant
H = int(input()) W = int(input()) N = int(input()) min_ops = H + W # Initialize with maximum possible value # Check all possible row operations and compute required column operations for r in range(H + 1): current = r * W if current >= N: if r < min_ops: min_ops = r continue needed = N - current available = H - r if available <= 0: continue required_c = (needed + available - 1) // available if required_c > W: continue total = r + required_c if total < min_ops: min_ops = total # Check all possible column operations and compute required row operations for c in range(W + 1): current = c * H if current >= N: if c < min_ops: min_ops = c continue needed = N - current available = W - c if available <= 0: continue required_r = (needed + available - 1) // available if required_r > H: continue total = c + required_r if total < min_ops: min_ops = total print(min_ops)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.