結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 8 ms
4,872 KB
testcase_15 AC 18 ms
7,580 KB
testcase_16 AC 17 ms
7,212 KB
testcase_17 AC 10 ms
5,140 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 16 ms
7,116 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 10 ms
5,424 KB
testcase_22 AC 14 ms
6,784 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 10 ms
5,160 KB
testcase_26 AC 18 ms
7,524 KB
testcase_27 AC 15 ms
6,684 KB
testcase_28 AC 21 ms
8,392 KB
testcase_29 AC 11 ms
5,692 KB
testcase_30 AC 10 ms
5,480 KB
testcase_31 AC 18 ms
7,472 KB
testcase_32 AC 12 ms
5,940 KB
testcase_33 AC 39 ms
13,084 KB
testcase_34 AC 37 ms
13,116 KB
testcase_35 AC 39 ms
13,096 KB
testcase_36 AC 40 ms
13,076 KB
testcase_37 AC 37 ms
13,060 KB
testcase_38 AC 38 ms
13,064 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;
    }
    cout<<dp[cnt][d]<<endl;
}
0