結果

問題 No.528 10^9と10^9+7と回文
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-10 20:47:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 76,864 KB
最終ジャッジ日時 2023-09-22 16:40:23
合計ジャッジ時間 5,125 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,056 KB
testcase_01 AC 73 ms
71,384 KB
testcase_02 AC 73 ms
71,060 KB
testcase_03 AC 71 ms
71,168 KB
testcase_04 AC 75 ms
71,308 KB
testcase_05 AC 72 ms
71,124 KB
testcase_06 AC 73 ms
71,236 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 157 ms
76,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
N = len(S)

M = 10 ** 9
P = 10 ** 9 + 7

ansM = 0
ansP = 0
for i in range(1, N):
    ansM += 9 * pow(10, (i-1)//2, M)
    ansM %= M
    ansP += 9 * pow(10, (i-1)//2, P)
    ansP %= P

X = S[:(N + 1) // 2]
Y = S[N // 2:][::-1]
cntM = 1
cntP = 1
for i, (x, y) in enumerate(zip(X, Y)):
    v = min(int(x), int(y))
    if i == 0:
        cntM = cntM * v % M
        cntP = cntP * v % P
    else:
        cntM = cntM * (v + 1) % M
        cntP = cntP * (v + 1) % P
ansM += cntM
ansM %= M
ansP += cntP
ansP %= P
print(ansM)
print(ansP)
0