結果

問題 No.1085 桁和の桁和
コンテスト
ユーザー tyawanmusi
提出日時 2020-01-20 19:01:30
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 593 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 594 ms
コンパイル使用メモリ 20,832 KB
実行使用メモリ 15,612 KB
最終ジャッジ日時 2026-04-03 11:43:11
合計ジャッジ時間 7,742 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 5 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

mod = 10**9 + 7
s=input()
d=int(input())
digit_sum=0
blind_count=0
for i in range(len(s)):
  if s[i]=="?":
    blind_count+=1
  else:
    digit_sum+=int(s[i])
    while digit_sum>9:
      digit_sum-=9
n=blind_count
r=[n]
l=[n+1]
d=[d]


def calc(l, r, di, dj):
  if dj == 0:
    if di == 0:
      return 1
    else:
      return 0
  else:
    ans_r = pow(10, r, mod) * pow(9, mod - 2, mod)
    ans_l = pow(10, l, mod) * pow(9, mod - 2, mod)
    ans=(ans_r + (mod - ans_l)) % mod
    if di == dj:
      ans += 1
      ans %= mod
    return ans
ans = calc(l[0], r[0], digit_sum, d[0])
print(ans)
0