結果
問題 |
No.1085 桁和の桁和
|
ユーザー |
![]() |
提出日時 | 2020-06-20 01:59:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 78,592 KB |
最終ジャッジ日時 | 2024-11-06 17:41:02 |
合計ジャッジ時間 | 4,525 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
import sys input = sys.stdin.readline T=input().strip() D=int(input()) mod=10**9+7 Q=0 W=0 for t in T: if t=="?": Q+=1 else: W+=int(t) DP=[0]*9 DP[W%9]=1 for t in range(Q): NDP=[0]*9 for i in range(9): for j in range(9): if i==j: NDP[j]+=DP[i]*2 else: NDP[j]+=DP[i] NDP[j]%=mod DP=NDP if D==0: if set(T)<={"0","?"}: print(1) else: print(0) elif D==9 and set(T)<={"0","?"}: print((DP[D%9]-1)%mod) else: print(DP[D%9]%mod)