跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2394. Magic Numbers

    ID: 2400 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>枚举贪心算法思想入门难度共享题库Codeforces英文题面题目来源题面语言

Magic Numbers

题目描述

A. Magic Numbers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
Input
114114
Output
YES
Input
1111
Output
YES
Input
441231
Output
NO

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2021 题。保留原作者与原赛事署名。