結果

問題 No.653 E869120 and Lucky Numbers
ユーザー lam6er
提出日時 2025-04-16 16:38:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 848 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 81,992 KB
実行使用メモリ 54,040 KB
最終ジャッジ日時 2025-04-16 16:40:31
合計ジャッジ時間 2,339 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

p = input().strip()

if not p.startswith('1'):
    print("No")
else:
    if len(p) == 1:
        print("No")
    else:
        s = p[1:]
        reversed_s = s[::-1]
        current_carries = {0}
        for c in reversed_s:
            current_digit = int(c)
            new_carries = set()
            for carry_in in current_carries:
                for a in [6, 7]:
                    for b in [6, 7]:
                        total = a + b + carry_in
                        mod = total % 10
                        if mod == current_digit:
                            carry_out = total // 10
                            new_carries.add(carry_out)
            current_carries = new_carries
            if not current_carries:
                break
        if 1 in current_carries:
            print("Yes")
        else:
            print("No")
0