結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,088 KB
testcase_01 AC 80 ms
15,328 KB
testcase_02 WA -
testcase_03 AC 81 ms
15,124 KB
testcase_04 WA -
testcase_05 AC 81 ms
15,304 KB
testcase_06 WA -
testcase_07 AC 81 ms
15,176 KB
testcase_08 AC 80 ms
15,272 KB
testcase_09 AC 82 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)
        if((i+1) != a.size)
            a[i + 1] += 2
        else
            a.push(2)
            a[i] %= 2
            break
        end
    end
    i += 1
end
a.reverse!
a.each do |d|
    if(d >= 2)
        print "hamu"
    else
        print "ham"
    end
end
puts ""
0