結果

問題 No.653 E869120 and Lucky Numbers
ユーザー 0w1
提出日時 2018-04-07 16:50:47
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 358 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-06-26 11:04:18
合計ジャッジ時間 4,075 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 23 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s = gets.strip.chars.map &:to_i
ng = false
cin = 0
s.reverse.each.with_index do |c, i|
  case c
  when 1
    if cin == 1 && i + 1 == s.size
      cin = 0
    else
      ng = true
    end
  when 2
    if cin == 0
      cin = 1
    else
      ng = true
    end
  when 3..4
    cin = 1
  else
    ng = true
  end
end
ng ||= cin > 0
puts [:Yes, :No][ng ? 1 : 0]
0