結果

問題 No.1085 桁和の桁和
ユーザー chocoruskchocorusk
提出日時 2020-06-19 22:05:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,376 bytes
コンパイル時間 1,215 ms
コンパイル使用メモリ 127,676 KB
実行使用メモリ 11,504 KB
最終ジャッジ日時 2023-09-30 06:07:29
合計ジャッジ時間 3,221 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,196 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 5 ms
11,184 KB
testcase_03 AC 4 ms
11,208 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 5 ms
11,256 KB
testcase_08 AC 4 ms
11,136 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 6 ms
11,236 KB
testcase_14 AC 11 ms
11,268 KB
testcase_15 AC 18 ms
11,368 KB
testcase_16 AC 18 ms
11,408 KB
testcase_17 AC 11 ms
11,460 KB
testcase_18 AC 8 ms
11,212 KB
testcase_19 AC 17 ms
11,288 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 12 ms
11,460 KB
testcase_22 AC 16 ms
11,504 KB
testcase_23 AC 6 ms
11,244 KB
testcase_24 AC 5 ms
11,200 KB
testcase_25 AC 12 ms
11,308 KB
testcase_26 AC 19 ms
11,412 KB
testcase_27 AC 16 ms
11,412 KB
testcase_28 AC 21 ms
11,272 KB
testcase_29 AC 13 ms
11,296 KB
testcase_30 AC 12 ms
11,304 KB
testcase_31 AC 19 ms
11,328 KB
testcase_32 AC 14 ms
11,308 KB
testcase_33 AC 30 ms
11,316 KB
testcase_34 AC 31 ms
11,268 KB
testcase_35 AC 31 ms
11,336 KB
testcase_36 AC 30 ms
11,328 KB
testcase_37 AC 30 ms
11,328 KB
testcase_38 AC 30 ms
11,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    string s; cin>>s;
    int n=s.size();
    int d; cin>>d;
    if(d==0){
        for(int i=0; i<n; i++){
            if(s[i]!='0' && s[i]!='?'){
                cout<<0<<endl;
                return 0;
            }
        }
        cout<<1<<endl;
        return 0;
    }
    ll dp[10][100010]={};
    dp[0][0]=1;
  ll c[9];
  for(int i=0; i<10; i++) c[i%9]++;
    for(int i=0; i<n; i++){
        if(s[i]!='?'){
            int x=s[i]-'0';
            for(int j=0; j<9; j++){
                (dp[(x+j)%9][i+1]+=dp[j][i])%=MOD;
            }
        }else{
            for(int x=0; x<9; x++){
                for(int j=0; j<9; j++){
                    (dp[(x+j)%9][i+1]+=c[x]*dp[j][i])%=MOD;
                }
            }
        }
    }
    cout<<dp[d%9][n]<<endl;
    return 0;
}
0