P0001. Upward numbers

We say that a natural number is upward if its digits fulfill the following property: on the right of a 0 can only be a 1, on the right of a 1 can only be a 2, on the right of a 2 can only be a 3, …, on the right of a 8 can only be a 9 and on the right of a 9 can only be a 0. For instance, 34567 and 8901 are upward, but 1223 and 245 are not.

Your task is to write a program that, given a sequence of natural numbers, indicates if this contains two or more consecutive upward numbers.

Your program must include the function

\begin{verbatim}
    bool is_upward(int n);
\end{verbatim}

that indicates if a natural number |n| is upward.

Input

The input is a sequence of natural numbers.

Output

If the input contains two upward consecutive numbers, your program must print “|YES|” in a line; otherwise print “|NO|” in a line.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:14:52.288Z

© Jutge.org, 2006–2026.
https://jutge.org