結果

問題 No.653 E869120 and Lucky Numbers
ユーザー yuruhiya
提出日時 2020-10-23 20:38:33
言語 Crystal
(1.14.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 14,826 ms
コンパイル使用メモリ 296,200 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 18:23:09
合計ジャッジ時間 15,931 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C
  fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end

class String
  def to_i64
    C.strtoll(self, nil, 10)
  end
end

def error
  puts "No"
  exit
end

s = read_line.chars.map(&.to_i).reverse
n = s.size
a = Array.new(n, 0)
n.times do |i|
  if s[i] == 0
    a[i] = 0
  elsif 2 <= s[i] <= 4
    a[i] = 1
    error if i == n - 1 || s[i + 1] == 0
    s[i + 1] -= 1
  elsif 6 <= s[i] <= 7
    a[i] = 2
  else
    error
  end
end

error if !a.join.match(/^1+2*0?$/)
puts "Yes"
0