結果

問題 No.423 ハムスター語初級(数詞)
ユーザー zazaboonzazaboon
提出日時 2017-01-29 14:25:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,420 KB
実行使用メモリ 15,308 KB
最終ジャッジ日時 2023-08-25 14:38:34
合計ジャッジ時間 1,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,152 KB
testcase_01 AC 82 ms
15,140 KB
testcase_02 AC 80 ms
15,140 KB
testcase_03 AC 80 ms
15,232 KB
testcase_04 AC 80 ms
15,116 KB
testcase_05 AC 81 ms
15,064 KB
testcase_06 AC 81 ms
15,124 KB
testcase_07 AC 81 ms
15,260 KB
testcase_08 AC 81 ms
15,152 KB
testcase_09 AC 80 ms
15,308 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:17: warning: possibly useless use of a variable in void context
Main.rb:27: warning: possibly useless use of a variable in void context
Syntax OK

ソースコード

diff #

s = gets.chomp
i = 0
a = []
while(i < s.size)
    if(i+3 < s.size and ((s[i..i+3]) == "hamu"))
        i += 4
        a.push(1)
    else
        i += 3
        a.push(0)
    end
end
a.reverse!
i = 0
while(i < a.size)
    if(a[i]%2 == 1)
        i
        if((i+1) != a.size)
            a[i + 1] += 2
        else
            a.push(2)
            break
        end
    end
    i += 1
end
a
a.reverse!
a.each do |d|
    if(d >= 2)
        print "hamu"
    else
        print "ham"
    end
end
puts ""
0