結果
| 問題 | No.1085 桁和の桁和 | 
| コンテスト | |
| ユーザー |  auaua | 
| 提出日時 | 2020-06-19 23:20:44 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,205 bytes | 
| コンパイル時間 | 1,760 ms | 
| コンパイル使用メモリ | 172,360 KB | 
| 実行使用メモリ | 13,568 KB | 
| 最終ジャッジ日時 | 2024-07-23 00:41:03 | 
| 合計ジャッジ時間 | 3,547 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 34 WA * 1 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    string t;cin>>t;
    ll d;cin>>d;
    ll sum=0;
    ll cnt=0;
    rep(i,t.size()){
        if(t[i]=='?')cnt++;
        else sum+=(t[i]-'0');
    }
    if(d==0){
        if(sum==0){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
        return 0;
    }
    vector<vector<ll> >dp(cnt+1,vector<ll>(9));
    if(sum==0){
        dp[cnt][0]=(dp[cnt][0]-1)%mod;
        if(dp[cnt][0]<0)dp[cnt][0]+=mod;
    }
    sum%=9;
    d%=9;
    dp[0][sum]=1;
    rep(i,cnt){
        rep(j,9){
            rep(k,10){
                dp[i+1][(j+k)%9]=(dp[i+1][(j+k)%9]+dp[i][j])%mod;
            }
            //cout<<dp[i][j]<<' ';
        }
        //cout<<endl;
    }
    cout<<dp[cnt][d]<<endl;
}
            
            
            
        