using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { List inpt = Reader.ReadLine().Select(a => int.Parse(a.ToString())).Reverse().ToList(); string ans = IsValid(inpt)?"Yes":"No"; Console.WriteLine(ans); } private bool IsValid(List inpt) { bool kuri = false; for (int i = 0; i < inpt.Count - 1; i++) { int num = inpt[i]; if(kuri) { if(num>0) { num--; kuri = false; } else { num = 9; } } if(num == 6 || num == 7) { if(i==0) { return false; } for (int j = i + 1; i < inpt.Count; i++) { if(inpt[j]!=6&&inpt[j]!=7) { return false; } } return true; } else if(num == 2 || num == 3 || num == 4) { if(i==inpt.Count-2) { if(inpt.Last() == 1) { return true; } else { return false; } } else { kuri = true; } } else { return false; } } return true; } public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 77784 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }