#P15040. [UOI 2022 II Stage] 竞赛

    ID: 16968 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度入门 上传者: 标签>模拟数学2022UOI(乌克兰)

[UOI 2022 II Stage] 竞赛

Problem Description

Xonia and her class arrive tt minutes before the contest starts. Due to epidemic prevention restrictions, the organizers allow students to enter the exam room in groups of mm every ww minutes.

In other words, the first group of mm students will enter the exam room tt minutes before the contest starts. The next group of mm students will enter t−wt-w minutes before the start. The next group of mm students will enter t−2wt-2w minutes before the start, and so on. Students may even enter at 00 minutes before the start (i.e., at the contest start time). However, students cannot enter after the contest starts.

There are nn 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 nn, mm, ww, tt (1≤n,m,w,t≤1 0001 \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.

5 2 3 4
4
6 3 2 4
6
10 3 3 6
9

Hint

Sample Explanation

Explanation of the first sample:

  • 44 minutes before the start, one group of two students enters the exam room.
  • 33 minutes before the start, the remaining three students wait.
  • 22 minutes before the start, the remaining three students wait.
  • 11 minute before the start, another group of two students enters the exam room.
  • 00 minutes before the start, the remaining one student waits. Since time is up, only four students successfully enter.

Explanation of the second sample:

  • 44 minutes before the start, one group of three students enters the exam room.
  • 33 minutes before the start, the remaining three students wait.
  • 22 minutes before the start, another group of three students can enter the exam room. Since there are no more students, all 66 students successfully enter.

Explanation of the third sample:

  • 66 minutes before the start, one group of three students enters the exam room.
  • 44 minutes before the start, the remaining seven students wait.
  • 33 minutes before the start, another group of three students can enter the exam room.
  • 11 minute before the start, the remaining four students wait.
  • 00 minutes before the start, one group of three students enters the exam room.
  • Time runs out, so a total of 99 students enter.

Translated by DeepSeek V3.

Translated by ChatGPT 5