結果

問題 No.1085 桁和の桁和
ユーザー tyawanmusityawanmusi
提出日時 2020-01-20 19:01:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-22 23:59:13
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 5 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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