結果

問題 No.1085 桁和の桁和
コンテスト
ユーザー rlangevin
提出日時 2023-08-01 12:35:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 366 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 125 ms
コンパイル使用メモリ 85,604 KB
実行使用メモリ 67,560 KB
最終ジャッジ日時 2026-04-27 10:45:36
合計ジャッジ時間 2,660 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

T = list(input())
D = int(input())
cnt, s = 0, 0
for t in T:
    if t == "?":
        cnt += 1
    else:
        s += int(t)
if s:
    s %= 9
    if s == 0:
        s = 9

if D == 0:
    if s == 0:
        print(1)
    else:
        print(0)
    exit()

mod = 10 ** 9 + 7
ans = pow(10, cnt, mod) - 1
ans *= pow(9, mod - 2, mod)
if s == D:
    ans += 1
print(ans%mod)
0