結果

問題 No.423 ハムスター語初級(数詞)
ユーザー quilt-tailsquilt-tails
提出日時 2016-11-15 23:40:20
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 290 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-08-17 07:09:41
合計ジャッジ時間 1,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,196 KB
testcase_01 AC 82 ms
15,336 KB
testcase_02 AC 83 ms
15,304 KB
testcase_03 AC 83 ms
15,300 KB
testcase_04 AC 83 ms
15,112 KB
testcase_05 AC 83 ms
15,240 KB
testcase_06 AC 83 ms
15,104 KB
testcase_07 AC 84 ms
15,244 KB
testcase_08 AC 84 ms
15,252 KB
testcase_09 AC 82 ms
15,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s = gets.chomp
a = s.scan(/hamu*/)
str = []
a.size.times do |i|
  if a[i] == "hamu"
    str << 1
  elsif a[i] == "ham"
    str << 0
  end
end
ans = str.join.to_i(2)*2
answer = ans.to_s(2)
answer.each_char do |i|
  if i == "1"
    print "hamu"
  elsif i == "0"
    print "ham"
  end
end
puts
0