結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:46:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 871 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,700 KB |
実行使用メモリ | 52,224 KB |
最終ジャッジ日時 | 2025-03-26 15:46:15 |
合計ジャッジ時間 | 1,306 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
s = input().strip() def parse_hamster(s): bits = [] i = 0 while i < len(s): # Check for 'hamu' (4 characters) if i + 4 <= len(s): token = s[i:i+4] if token == 'hamu': bits.append('1') i += 4 continue # Check for 'ham' (3 characters) if i + 3 <= len(s): token = s[i:i+3] if token == 'ham': bits.append('0') i += 3 continue # According to problem statement, input is valid, so this part is unreachable return ''.join(bits) bits_str = parse_hamster(s) num = int(bits_str, 2) if bits_str else 0 doubled = num * 2 binary_str = bin(doubled)[2:] if doubled != 0 else '0' result = [] for c in binary_str: result.append('hamu' if c == '1' else 'ham') print(''.join(result))