No.396 Class Reassignment
タグ : / 解いたユーザー数 277
作問者 :
koyumeishi
/ テスター :
りあん
Problem Statement
The time for class reassignment has come again this year.
Every year, the private Yuki High School uses the following algorithm to assign $N$ students to $M$ classes.
1) Line up the students in order of their grades (from the front: rank $1$, rank $2$, rank $3$, $\dots$ , rank $N$)
2) Starting from the front of the line, assign $M$ students in order to Class $1$, Class $2$, $\dots$ , Class $M-1$, Class $M$, and remove them from the line. If the end of the line is reached partway through, the process ends there
3) Assign the next $M$ students in order to Class $M$, Class $M-1$, $\dots$ , Class $2$, Class $1$, and remove them from the line. If the end of the line is reached partway through, the process ends there
4) Return to 2)
Now, Hanako, a student at Yuki High School, ranked $X$-th out of $N$ students in this school year's grades.
Taro, the person Hanako has a crush on, ranked $Y$-th out of $N$ students.
Determine whether Hanako and Taro can be in the same class next school year.
Print "$YES$" if they can be in the same class, and "$NO$" if they cannot.
No two people have the same rank in the grade order.
Input
The first line gives the number of students $N$ and the number of classes $M$.
The second line gives Hanako's rank $X$ and Taro's rank $Y$.
$N$ $M$ $X$ $Y$
All input values are integers and satisfy the following constraints.
$2 \leq N \leq 10^9$
$1 \leq M \leq 10^9$
$1 \leq X \leq N$
$1 \leq Y \leq N$
$X \neq Y$
Output
Print "$YES$" if they can be in the same class, and "$NO$" if they cannot. Print a newline at the end.
Sample
Sample 1
Input
10 4 4 5
Output
YES
Congratulations! Hanako and Taro will both be in Class 4 next school year!
Sample 2
Input
50 40 50 1
Output
NO
Too bad, Hanako is in Class 31 and Taro is in Class 1.
Sample 3
Input
150 7 63 35
Output
YES
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。