結果

問題 No.1085 桁和の桁和
ユーザー tyawanmusityawanmusi
提出日時 2020-01-20 19:25:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 878 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-24 10:00:29
合計ジャッジ時間 3,139 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 53 ms
11,008 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 33 ms
10,752 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 32 ms
10,752 KB
testcase_11 AC 32 ms
10,880 KB
testcase_12 AC 31 ms
10,880 KB
testcase_13 AC 36 ms
10,752 KB
testcase_14 AC 46 ms
11,008 KB
testcase_15 AC 68 ms
11,136 KB
testcase_16 AC 67 ms
11,136 KB
testcase_17 AC 47 ms
10,880 KB
testcase_18 AC 39 ms
10,880 KB
testcase_19 AC 64 ms
11,136 KB
testcase_20 AC 64 ms
11,008 KB
testcase_21 AC 52 ms
10,880 KB
testcase_22 AC 59 ms
10,880 KB
testcase_23 AC 33 ms
10,752 KB
testcase_24 AC 31 ms
10,752 KB
testcase_25 AC 50 ms
10,880 KB
testcase_26 AC 69 ms
11,008 KB
testcase_27 AC 60 ms
11,008 KB
testcase_28 AC 73 ms
11,008 KB
testcase_29 AC 53 ms
11,008 KB
testcase_30 AC 52 ms
10,880 KB
testcase_31 AC 67 ms
11,136 KB
testcase_32 AC 54 ms
11,008 KB
testcase_33 AC 54 ms
11,008 KB
testcase_34 AC 55 ms
11,008 KB
testcase_35 AC 53 ms
11,008 KB
testcase_36 AC 54 ms
11,136 KB
testcase_37 AC 56 ms
11,008 KB
testcase_38 AC 54 ms
11,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

def calc(l, r, di, dj):
  #(10^l <= a < 10^r or a=0) and f(di+f(a))=djを満たすaの数
  if dj == 0:
    if di == 0:
      #di==dj==0のとき、a=0の1通りのみ
      return 1
    else:
      #di!=dj==0のとき、条件を満たすaは存在しない
      return 0
  else:
    #aの総数は(10^r - 10^l)/9で一般化される
    #di==djの時、a=0の1通りが加算される
    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(0, blind_count, digit_sum, d)
print(ans)
0