結果
| 問題 |
No.1085 桁和の桁和
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2020-06-19 22:01:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 531 bytes |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 72,320 KB |
| 最終ジャッジ日時 | 2024-11-06 17:34:16 |
| 合計ジャッジ時間 | 3,492 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
ソースコード
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
#n,k,*a = map(int,read().split())
t = input()
d = int(input())
r = 0 #?以外の桁和
dp = [0]*9
dp[0] = 1
s = 1 # sum(dp)
MOD = 10**9+7
for i in t:
if i!="?":
r += int(i)
else:
for j in range(9):
dp[j] = (dp[j]+s)%MOD
s *= 10
s %= MOD
#print(dp)
if d==0:
if r==0: print(1)
else: print(0)
elif r==0 and d==9: print(dp[0]-1)
else:
print(dp[(d-r)%9])
convexineq