結果

問題 No.1085 桁和の桁和
ユーザー milanis48663220milanis48663220
提出日時 2020-06-19 23:02:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,087 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 82,956 KB
実行使用メモリ 11,332 KB
最終ジャッジ日時 2023-09-30 06:25:44
合計ジャッジ時間 2,412 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 RE -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 10 ms
6,360 KB
testcase_15 AC 20 ms
10,112 KB
testcase_16 AC 20 ms
10,044 KB
testcase_17 AC 10 ms
6,656 KB
testcase_18 AC 6 ms
4,956 KB
testcase_19 AC 17 ms
9,404 KB
testcase_20 RE -
testcase_21 AC 12 ms
7,180 KB
testcase_22 AC 16 ms
9,024 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 11 ms
6,828 KB
testcase_26 AC 20 ms
10,300 KB
testcase_27 AC 16 ms
8,972 KB
testcase_28 AC 22 ms
11,332 KB
testcase_29 AC 14 ms
7,588 KB
testcase_30 AC 12 ms
7,452 KB
testcase_31 AC 20 ms
10,072 KB
testcase_32 AC 14 ms
7,920 KB
testcase_33 AC 31 ms
11,232 KB
testcase_34 AC 32 ms
11,308 KB
testcase_35 AC 31 ms
11,224 KB
testcase_36 AC 31 ms
11,304 KB
testcase_37 AC 30 ms
11,244 KB
testcase_38 AC 31 ms
11,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll dp[100001][10];

string T;
int D;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> T >> D;
    dp[0][0] = 1;
    int N = T.size();
    if(D == 0){
        for(int i = 0; i < N; i++){
            if(T[i] != '0' && T[i] != '?'){
                cout << 0 << endl;
                return -1;
            }
        }
        cout << 1 << endl;
        return -1;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 9; j++){
            if(T[i] == '?'){
                for(int k = 0; k < 10; k++){
                    dp[i+1][(j+k)%9] += dp[i][j];
                    dp[i+1][(j+k)%9] %= MOD;
                }
            }else{
                int k = T[i]-'0';
                dp[i+1][(j+k)%9] += dp[i][j];
                dp[i+1][(j+k)%9] %= MOD;
            }
        }
    }
    cout << dp[N][D%9] << endl;
}
0