結果

問題 No.1085 桁和の桁和
ユーザー auauaauaua
提出日時 2020-06-19 23:19:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,205 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 170,380 KB
実行使用メモリ 13,380 KB
最終ジャッジ日時 2023-09-30 06:28:04
合計ジャッジ時間 3,076 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 8 ms
4,876 KB
testcase_15 AC 17 ms
7,572 KB
testcase_16 AC 16 ms
7,616 KB
testcase_17 AC 8 ms
5,136 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 15 ms
7,012 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 10 ms
5,460 KB
testcase_22 AC 14 ms
6,768 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 9 ms
5,244 KB
testcase_26 AC 17 ms
7,576 KB
testcase_27 AC 15 ms
6,724 KB
testcase_28 AC 21 ms
8,344 KB
testcase_29 AC 10 ms
5,708 KB
testcase_30 AC 9 ms
5,432 KB
testcase_31 AC 18 ms
7,552 KB
testcase_32 AC 12 ms
6,060 KB
testcase_33 AC 36 ms
13,312 KB
testcase_34 AC 35 ms
13,084 KB
testcase_35 AC 35 ms
13,380 KB
testcase_36 AC 35 ms
13,064 KB
testcase_37 AC 35 ms
13,152 KB
testcase_38 AC 34 ms
13,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
    sum%=9;
    d%=9;
    vector<vector<ll> >dp(cnt+1,vector<ll>(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;
    }
    if(sum==0){
        dp[cnt][0]=(dp[cnt][0]-1)%mod;
        if(dp[cnt][0]<0)dp[cnt][0]+=mod;
    }
    cout<<dp[cnt][d]<<endl;
}
0