Preparando MOJI

Magic Numbers

2000ms 262144K

Description:

A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.

You're given a number. Determine if it is a magic number or not.

Input:

The first line of input contains an integer n, (1 ≤ n ≤ 109). This number doesn't contain leading zeros.

Output:

Print "YES" if n is a magic number or print "NO" if it's not.

Sample Input:

114114

Sample Output:

YES

Sample Input:

1111

Sample Output:

YES

Sample Input:

441231

Sample Output:

NO

Informação

Codeforces

Provedor Codeforces

Código CF320A

Tags

brute forcegreedy

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:44:54

Relacionados

Nada ainda