結果

問題 No.1085 桁和の桁和
ユーザー rlangevin
提出日時 2023-08-01 12:29:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 80,480 KB
最終ジャッジ日時 2024-10-11 04:18:26
合計ジャッジ時間 3,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    val = 0
    for s in str(x):
        val += int(s)
    return val

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

for _ in range(10**4):
    s = f(s)

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