結果

問題 No.653 E869120 and Lucky Numbers
ユーザー mai
提出日時 2018-02-23 22:52:01
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-10-09 20:22:03
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

str = gets.chomp.reverse

termflg = false
zeroflg = false
str.chars.each_index do |i|
    u = str[i].to_i
    #p [u,i,[termflg, zeroflg]]
    if !zeroflg
        if u != 2 && u != 3 && u != 4
            zeroflg = true
            redo
        end
        str[i+1] = (str[i+1].to_i-1).to_s
    else
        if i == 0
            puts "No"; exit
        end
        if termflg && u != 0
            puts "No"; exit
        end
        if u != 6 && u != 7
            if u == 0
                termflg = true
            else
                puts "No"; exit
            end
        end
    end
end

puts "Yes"; exit
0