結果

問題 No.423 ハムスター語初級(数詞)
ユーザー 👑 yumechiyumechi
提出日時 2016-11-02 07:28:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 71,496 KB
最終ジャッジ日時 2023-08-16 12:34:25
合計ジャッジ時間 1,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,328 KB
testcase_01 AC 70 ms
71,328 KB
testcase_02 AC 72 ms
71,208 KB
testcase_03 AC 70 ms
71,484 KB
testcase_04 AC 71 ms
71,496 KB
testcase_05 AC 70 ms
71,304 KB
testcase_06 AC 72 ms
71,028 KB
testcase_07 AC 70 ms
71,384 KB
testcase_08 AC 71 ms
71,452 KB
testcase_09 AC 71 ms
71,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    numarr = ["hamu", "ham"]
    s = input()
    numstr = ""
    for idx in range(2):
        s = s.replace(numarr[idx], str(1 - idx))
    ansnum = int(s, 2) * 2
    ans = []
    while ansnum > 0:
        ans.append(numarr[(ansnum & 1) ^ 1])
        ansnum >>= 1
    print("".join(ans[::-1]) if len(ans) > 0 else "ham")

if __name__=="__main__":
    solve()
0