結果

問題 No.653 E869120 and Lucky Numbers
ユーザー titia
提出日時 2024-07-05 05:12:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 946 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-05 05:12:59
合計ジャッジ時間 2,186 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

S=list(input().strip())

S.reverse()
while S:
    if S and S[-1]=="6":
        S.pop()
        if S[-1]=="1":
            print("No")
            exit()
        continue

    if S[-1]=="7":
        if len(S)==1:
            S.pop()
            continue
        if S[-2]=="6" or S[-2]=="7" or S[-2]=="8":
            S.pop()
            continue
        S.pop()
        S.append("1")
        break

    if S[-1]=="8":
        S.pop()
        S.append("1")
        break

    break

if len(S)==0:
    print("Yes")
    exit()

while S:
    if len(S)==1:
        print("No")
        exit()
    x=S.pop()
    y=S.pop()

    if x=="1" and y=="2":
        continue

    if x=="1" and (y=="3" or y=="4"):
        if S:
            S.append("1")
            continue
        else:
            continue

    if x=="1" and y=="5":
        S.append("1")
        continue

    print("No")
    exit()

print("Yes")

    
0