結果
| 問題 |
No.423 ハムスター語初級(数詞)
|
| コンテスト | |
| ユーザー |
naotest2
|
| 提出日時 | 2017-05-26 18:49:24 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 415 bytes |
| コンパイル時間 | 87 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-09-19 20:08:15 |
| 合計ジャッジ時間 | 1,572 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 WA * 1 |
コンパイルメッセージ
Main.rb:15: warning: possibly useless use of * in void context Syntax OK
ソースコード
S=gets.chomp
S.gsub!(/hamu/, '1')
S.gsub!(/ham/, '0')
def to10(str)
r = 0
for i in 0..(str.length-1)
r += (2 ** (str.length-1-i)) * str[i].to_i
end
return r
end
to10(S) * 2
def to2(num)
s = ""
while num > 0
if num % 2 == 1
s += "1"
else
s += "0"
end
num = num >> 1
end
return s.reverse
end
k = to2(to10(S) * 2)
k.gsub!(/1/, 'hamu')
k.gsub!(/0/, 'ham')
puts k
naotest2