結果

問題 No.1085 桁和の桁和
ユーザー tyawanmusityawanmusi
提出日時 2020-01-03 19:05:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 91,776 KB
最終ジャッジ日時 2024-04-24 10:00:11
合計ジャッジ時間 6,165 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,096 KB
testcase_01 AC 35 ms
51,968 KB
testcase_02 AC 34 ms
52,096 KB
testcase_03 AC 36 ms
52,480 KB
testcase_04 AC 256 ms
91,008 KB
testcase_05 AC 34 ms
51,840 KB
testcase_06 AC 35 ms
51,584 KB
testcase_07 AC 33 ms
52,096 KB
testcase_08 AC 34 ms
51,968 KB
testcase_09 AC 35 ms
51,840 KB
testcase_10 AC 35 ms
51,968 KB
testcase_11 AC 36 ms
51,968 KB
testcase_12 AC 41 ms
60,544 KB
testcase_13 AC 64 ms
67,968 KB
testcase_14 AC 95 ms
78,720 KB
testcase_15 AC 148 ms
83,200 KB
testcase_16 AC 152 ms
82,816 KB
testcase_17 AC 103 ms
78,976 KB
testcase_18 AC 74 ms
71,424 KB
testcase_19 AC 136 ms
81,920 KB
testcase_20 AC 138 ms
81,920 KB
testcase_21 AC 109 ms
80,000 KB
testcase_22 AC 134 ms
81,792 KB
testcase_23 AC 58 ms
66,432 KB
testcase_24 AC 47 ms
61,440 KB
testcase_25 AC 108 ms
79,488 KB
testcase_26 AC 152 ms
83,456 KB
testcase_27 AC 131 ms
81,664 KB
testcase_28 AC 158 ms
84,224 KB
testcase_29 AC 112 ms
80,256 KB
testcase_30 AC 107 ms
79,872 KB
testcase_31 AC 146 ms
82,816 KB
testcase_32 AC 120 ms
80,768 KB
testcase_33 AC 260 ms
91,648 KB
testcase_34 AC 252 ms
91,392 KB
testcase_35 AC 256 ms
91,392 KB
testcase_36 AC 259 ms
91,520 KB
testcase_37 AC 256 ms
91,776 KB
testcase_38 AC 266 ms
91,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()
d=int(input())
mod=10**9+7
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

dp=[10*[0]for _ in range(blind_count+1)]
dp[0][0]=1
for i in range(1,blind_count+1):
  for j in range(10):
    for k in range(10):
      jk=j+k
      if jk>9:
        jk-=9
      dp[i][jk]+=dp[i-1][j]
      dp[i][jk]%=mod

if d==0:
    if digit_sum==0:
        print(1)
    else:
        print(0)
    exit()

if digit_sum<d:
    n=d-digit_sum
else:
    n=d-digit_sum+9
ans=dp[blind_count][n]
if digit_sum==d:ans+=1
print(ans)
0