結果

問題 No.423 ハムスター語初級(数詞)
ユーザー takaaaa6takaaaa6
提出日時 2022-03-09 00:28:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-10-09 21:02:14
合計ジャッジ時間 1,061 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,956 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 16 ms
7,816 KB
testcase_03 AC 16 ms
7,772 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 15 ms
7,856 KB
testcase_06 AC 16 ms
7,864 KB
testcase_07 AC 16 ms
7,740 KB
testcase_08 AC 15 ms
7,864 KB
testcase_09 AC 16 ms
7,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=input()
l=list()

for i in range(len(n)):
    if n[i] == 'm' and i+1 < len(n):
        if n[i+1] == 'u':
            l.append(1)
        elif n[i+1] == 'h':
            l.append(0)

    elif n[i] == 'm' and i == len(n)-1:
        l.append(0)

#print(l)

sum=0
for j in range(len(l)):
    sum += l[j] * 2**(len(l)-1-j)
sum *= 2
#print(sum)

amari=[]
if sum == 0:
    amari.append(0)
while sum != 0:
    amari.append(sum%2)
    sum //= 2
amari.reverse()

#print(amari)

hm=[]
for k in range(len(amari)):
    if amari[k] == 0:
        hm.append("ham")
    else:
        hm.append("hamu")

print("".join(hm))
0