#P11506. Determine the Floor of a Room in the Campus Dormitory

    ID: 13592 Type: Default 1000ms 256MiB

Determine the Floor of a Room in the Campus Dormitory

Determine the Floor of a Room in the Campus Dormitory

The new campus building of Bytetown University has n floors, numbered from 1 to n from bottom to top. Each corridor within the building assigns rooms to floors with a special rule. In each corridor, if the floor number is a multiple of k, that floor has x rooms; otherwise it has y rooms. The rooms in each corridor are numbered sequentially by floor, starting from the first floor, then the second, and so on. The first corridor's room numbering starts from 1, and each subsequent corridor continues the numbering from the last room number of the previous corridor.

For example, if n = 7, number of corridors is 3, k = 3, x = 2, and y = 3, then the room distribution per corridor is as follows:

  • Floor 1: 3 rooms
  • Floor 2: 3 rooms
  • Floor 3: 2 rooms (since 3 is a multiple of 3)
  • Floor 4: 3 rooms
  • Floor 5: 3 rooms
  • Floor 6: 2 rooms (since 6 is a multiple of 3)
  • Floor 7: 3 rooms

Given the values of n, k, x, y, and a room number, your task is to determine which floor (within the respective corridor) that room is located on.

Note: All mathematical formulas must be represented in LaTeX format. For example, the total number of rooms in a corridor can be calculated as:

[ T = \sum_{i=1}^{n} \begin{cases} x, & \text{if } i \equiv 0 \pmod{k} \ y, & \text{otherwise} \end{cases} ]

inputFormat

The first line contains four space-separated integers: \(n\), \(k\), \(x\), and \(y\).

The second line contains a single integer representing the room number to query.

outputFormat

Output a single integer representing the floor number within the corridor where the queried room is located.

sample

7 3 2 3
2
1

</p>