結果

問題 No.3053 $((0 \And 1)\mathop{|}2)\oplus 3$
ユーザー 👑 rin204
提出日時 2025-02-05 20:18:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 396 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 79,432 KB
最終ジャッジ日時 2025-03-08 00:10:57
合計ジャッジ時間 3,507 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
S = input()[::-1]

three = 3
c0 = 2 * pow(3, -1, MOD) % MOD
all_ = c0
t = c0
two = 1
ans = 0
for s in S:
    if s == "1":
        ans = (ans + two) % MOD
        all_ = (all_ * three) % MOD
        t = (t * c0) % MOD
    else:
        ans = (ans + two * t % MOD) % MOD

    three = (three * three) % MOD
    two = (two * 2) % MOD
    c0 = (c0 * c0) % MOD

print(ans * all_ % MOD)
0