P15040 [UOI 2022 II Stage] Contest
Description
Xonia and her class arrive $t$ minutes before the contest starts. Due to epidemic prevention restrictions, the organizers allow students to enter the exam room in groups of $m$ every $w$ minutes.
In other words, the first group of $m$ students will enter the exam room $t$ minutes before the contest starts. The next group of $m$ students will enter $t-w$ minutes before the start. The next group of $m$ students will enter $t-2w$ minutes before the start, and so on. Students may even enter at $0$ minutes before the start (i.e., at the contest start time). However, students cannot enter after the contest starts.
There are $n$ students in total in the class (including Xonia). How many students can enter the exam room before the contest starts?
Input Format
The first line contains four integers $n$, $m$, $w$, $t$ ($1 \leq n, m, w, t \leq 1\,000$).
Output Format
Output one number —— the number of students who can arrive in time for the contest.
Explanation/Hint
### Sample Explanation
Explanation of the first sample:
- $4$ minutes before the start, one group of two students enters the exam room.
- $3$ minutes before the start, the remaining three students wait.
- $2$ minutes before the start, the remaining three students wait.
- $1$ minute before the start, another group of two students enters the exam room.
- $0$ minutes before the start, the remaining one student waits. Since time is up, only four students successfully enter.
Explanation of the second sample:
- $4$ minutes before the start, one group of three students enters the exam room.
- $3$ minutes before the start, the remaining three students wait.
- $2$ minutes before the start, another group of three students can enter the exam room. Since there are no more students, all $6$ students successfully enter.
Explanation of the third sample:
- $6$ minutes before the start, one group of three students enters the exam room.
- $4$ minutes before the start, the remaining seven students wait.
- $3$ minutes before the start, another group of three students can enter the exam room.
- $1$ minute before the start, the remaining four students wait.
- $0$ minutes before the start, one group of three students enters the exam room.
- Time runs out, so a total of $9$ students enter.
Translated by DeepSeek V3.
Translated by ChatGPT 5