結果

問題 No.653 E869120 and Lucky Numbers
ユーザー yuruhiyayuruhiya
提出日時 2020-10-23 20:38:33
言語 Crystal
(1.11.2)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 22,161 ms
コンパイル使用メモリ 255,384 KB
実行使用メモリ 5,200 KB
最終ジャッジ日時 2023-10-11 19:31:36
合計ジャッジ時間 23,617 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,812 KB
testcase_01 AC 3 ms
4,564 KB
testcase_02 AC 3 ms
4,900 KB
testcase_03 AC 2 ms
4,736 KB
testcase_04 AC 2 ms
4,612 KB
testcase_05 AC 3 ms
4,824 KB
testcase_06 AC 3 ms
4,904 KB
testcase_07 AC 3 ms
4,892 KB
testcase_08 AC 3 ms
4,876 KB
testcase_09 AC 3 ms
4,716 KB
testcase_10 AC 2 ms
4,548 KB
testcase_11 AC 3 ms
4,788 KB
testcase_12 AC 3 ms
4,496 KB
testcase_13 AC 3 ms
4,912 KB
testcase_14 AC 3 ms
4,756 KB
testcase_15 AC 3 ms
4,696 KB
testcase_16 AC 3 ms
4,816 KB
testcase_17 AC 2 ms
4,476 KB
testcase_18 AC 3 ms
4,608 KB
testcase_19 AC 3 ms
4,560 KB
testcase_20 AC 2 ms
4,476 KB
testcase_21 AC 3 ms
4,544 KB
testcase_22 AC 3 ms
4,588 KB
testcase_23 AC 3 ms
4,776 KB
testcase_24 AC 3 ms
4,516 KB
testcase_25 AC 3 ms
4,704 KB
testcase_26 AC 2 ms
4,576 KB
testcase_27 AC 2 ms
4,484 KB
testcase_28 AC 3 ms
5,200 KB
testcase_29 AC 3 ms
5,136 KB
testcase_30 AC 3 ms
4,836 KB
testcase_31 AC 3 ms
4,540 KB
testcase_32 AC 3 ms
4,828 KB
testcase_33 AC 3 ms
4,896 KB
権限があれば一括ダウンロードができます

ソースコード

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