题库练习 Circle Metro
← 上一题 下一题 →

A12607 | Circle Metro

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

The circle line of the Roflanpolis subway has $n$ stations.

There are two parallel routes in the subway. The first one visits stations in order $1 \to 2 \to \ldots \to n \to 1 \to 2 \to \ldots$ (so the next stop after station $x$ is equal to $(x+1)$ if $x < n$ and $1$ otherwise). The second route visits stations in order $n \to (n-1) \to \ldots \to 1 \to n \to (n-1) \to \ldots$ (so the next stop after station $x$ is equal to $(x-1)$ if $x>1$ and $n$ otherwise). All trains depart their stations simultaneously, and it takes exactly $1$ minute to arrive at the next station.

Two toads live in this city, their names are Daniel and Vlad.

Daniel is currently in a train of the first route at station $a$ and will exit the subway when his train reaches station $x$ .

Coincidentally, Vlad is currently in a train of the second route at station $b$ and he will exit the subway when his train reaches station $y$ .

Surprisingly, all numbers $a,x,b,y$ are distinct.

Toad Ilya asks you to check if Daniel and Vlad will ever be at the same station at the same time during their journey. In other words, check if there is a moment when their trains stop at the same station. Note that this includes the moments when Daniel or Vlad enter or leave the subway.

输入格式

The first line contains five space-separated integers $n$ , $a$ , $x$ , $b$ , $y$ ( $4 \leq n \leq 100$ , $1 \leq a, x, b, y \leq n$ , all numbers among $a$ , $x$ , $b$ , $y$ are distinct) — the number of stations in Roflanpolis, Daniel's start station, Daniel's finish station, Vlad's start station and Vlad's finish station, respectively.

输出格式

Output "YES" if there is a time moment when Vlad and Daniel are at the same station, and "NO" otherwise. You can print each letter in any case (upper or lower).

输入输出样例

输入 #1
5 1 4 3 2
输出 #1
YES
输入 #2
10 2 1 9 10
输出 #2
NO
C++ 编辑器
输入
输出