結果

問題 No.2019 Digits Filling for All Substrings
ユーザー ShirotsumeShirotsume
提出日時 2022-02-07 10:52:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 551 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 83,864 KB
最終ジャッジ日時 2023-09-02 19:16:03
合計ジャッジ時間 4,266 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
75,784 KB
testcase_01 AC 71 ms
71,524 KB
testcase_02 AC 71 ms
71,448 KB
testcase_03 AC 81 ms
76,604 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

s = input()
mod = 998244353
def solve(s, l, r):
    sn = s[l:r + 1]
    q = 0
    summ = 0
    for i in range(len(sn)):
        if sn[i] == '?':
            q += 1
        else:
            summ += int(sn[i])
    if summ % 3 == 0:
        ret = (pow(10, q, mod) - 1) * pow(3, mod - 2, mod) + 1
        ret %= mod
    else:
        ret = (pow(10, q, mod) - 1) * pow(3, mod - 2, mod)
        ret %= mod
    return ret

ans = 0
for l in range(0, n):
    for r in range(l, n):
        ans += solve(s, l, r)
        ans %= mod
print(ans)
0