結果
問題 | No.2147 ハノイの塔のおもちゃ |
ユーザー | trineutron |
提出日時 | 2022-12-04 05:50:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 214 bytes |
コンパイル時間 | 84 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-10-11 06:52:13 |
合計ジャッジ時間 | 1,024 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 |
ソースコード
mod = 10**9 + 7 n = int(input()) s = input() ans = 0 last = 0 for c in s[::-1]: ans *= 2 ans %= mod x = ord(c) - ord('A') if x != last: ans += 1 last = (-x - last) % 3 print(ans)