結果

問題 No.423 ハムスター語初級(数詞)
ユーザー harhogefooharhogefoo
提出日時 2016-10-12 11:34:50
言語 Ruby
(3.3.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 11,372 KB
実行使用メモリ 15,304 KB
最終ジャッジ日時 2023-08-14 07:40:22
合計ジャッジ時間 1,707 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
15,292 KB
testcase_01 AC 70 ms
15,080 KB
testcase_02 AC 73 ms
15,076 KB
testcase_03 AC 71 ms
15,092 KB
testcase_04 AC 69 ms
14,980 KB
testcase_05 AC 71 ms
15,304 KB
testcase_06 AC 70 ms
15,056 KB
testcase_07 AC 69 ms
15,200 KB
testcase_08 AC 70 ms
15,156 KB
testcase_09 AC 69 ms
15,296 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp
ary = Array.new

loop do
  if n[0,4] == "hamu"
    ary.push(1)
    n[0,4] = ""
  else
    ary.push(0)
    n[0,3] = ""
  end
  break if n.length == 0
end
ans = ary.join.to_i(2) * 2
if not ans.to_s(2).include?("1")
  puts "#{ans.to_s(2).gsub!(/0/, 'ham')}"
elsif not ans.to_s(2).include?("0")
  puts "#{ans.to_s(2).gsub!(/1/, 'hamu')}"
else
  puts "#{ans.to_s(2).gsub!(/1/, 'hamu').gsub!(/0/, 'ham')}"
end
0