結果
| 問題 | No.1085 桁和の桁和 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-19 23:33:52 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 35 ms / 2,000 ms | 
| コード長 | 1,134 bytes | 
| コンパイル時間 | 1,778 ms | 
| コンパイル使用メモリ | 166,904 KB | 
| 実行使用メモリ | 11,520 KB | 
| 最終ジャッジ日時 | 2024-11-06 17:40:06 | 
| 合計ジャッジ時間 | 3,201 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 35 | 
ソースコード
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[100010][10] = {};
void solve(){
    string T;
    cin >> T;
    ll D;
    cin >> D;
    dp[0][0] = 1;
    ll N = T.size();
    rep(i,0,N){
        rep(j,0,10){
            if(T[i] == '?'){
                rep(k,0,10){
                    ll n = k + j;
                    if(n >= 10) n = n / 10 + n % 10;
                    (dp[i+1][n] += dp[i][j]) %= MOD;
                }
            }else{
                ll n = T[i] - '0' + j;
                if(n >= 10) n = n / 10 + n % 10;
                (dp[i+1][n] += dp[i][j]) %= MOD;
            }
        }
    }
    print(dp[N][D]);
    
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
            
            
            
        