結果

問題 No.884 Eat and Add
ユーザー yuruhiyayuruhiya
提出日時 2020-10-22 22:53:02
言語 Crystal
(1.11.2)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 411 bytes
コンパイル時間 18,645 ms
コンパイル使用メモリ 264,464 KB
実行使用メモリ 5,988 KB
最終ジャッジ日時 2023-09-13 12:27:04
合計ジャッジ時間 17,867 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,540 KB
testcase_01 AC 3 ms
4,404 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 8 ms
5,980 KB
testcase_04 AC 7 ms
5,972 KB
testcase_05 AC 6 ms
5,856 KB
testcase_06 AC 6 ms
5,892 KB
testcase_07 AC 6 ms
5,824 KB
testcase_08 AC 5 ms
5,872 KB
testcase_09 AC 6 ms
5,988 KB
testcase_10 AC 2 ms
4,412 KB
testcase_11 AC 2 ms
4,404 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

s = (read_line.reverse + '0').chars
n = s.size
ans = 0
(0...n).each do |i|
  if s[i] == '1'
    if (s[i + 1]? || '0') == '0'
      s[i] = '0'
    else
      while s[i] == '1'
        s[i] = '0'
        i += 1
      end
      s[i] = '1'
    end
    ans += 1
  end
end
puts ans
0