Elevators
InterviewTime limit1sMemory limit1024 MB
Given a zoning district and a floor count between 1 and 20, look up the required number of elevators from a fixed table.
- Level
Easy2 of 10
- Topics
- Implementation, Brute force, Array
- Solved
- No attempts yet
Problem
Whenever a new building is built, it must comply with all the relevant building regulations. In particular, there are rules governing the number of elevators a building must have depending on its number of floors and zoning district.
If a building has only one floor, it doesn't need any elevators; otherwise, it needs more elevators the more floors it has, and the exact number depends on its zoning district. The following tables describe the number of elevators necessary for a building in each of the residential, commercial, and industrial zoning districts.
Table 1: Elevator requirements by zone
You are given the zoning district of a new building and how many floors it has. How many elevators does it need?
Input
The only line of input contains a string representing the zoning district of the building ("residential", "commercial", or "industrial"), followed by a space and an integer (), the number of floors the building has.
Output
Output a single integer: the number of elevators the building must have.