結果

問題 No.1085 桁和の桁和
ユーザー ShibuyapShibuyap
提出日時 2020-06-20 00:01:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,202 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 200,024 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2023-09-30 06:28:41
合計ジャッジ時間 3,328 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 23 ms
6,912 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 11 ms
4,868 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 1000000
int dp[MAX_N] = {};
int main() {
    string t;
    cin >> t;
    int d;
    cin >> d;
    int n = 0;
    int sum = 0;
    rep(i,t.size()){
        if(t[i] == '?')n++;
        else sum += t[i] - '0';
    }

    int dp[n][9];
    rep(i,n)rep(j,9)dp[i][j] = 0;
    ll MOD = 1e9+7;
    rep(i,n){
        if(i == 0){
            rep(j,9)dp[i][j] = 1;
            dp[i][0] = 2;
        }else{
            rep(j,9){
                rep(k,10){
                    dp[i][(j+k)%9] += dp[i-1][j];
                }
            }
            rep(j,9)dp[i][j] %= MOD;
        }
    }
    if(sum == 0){
        dp[n-1][0] += MOD - 1;
    }
    int ans = 0;
    if(d == 0){
        if(sum == 0){
            ans = 1;
        }
        cout << ans << endl;
        return 0;
    }
    sum %= 9;
    d = d + 9 - sum;
    d %= 9;

    ans = dp[n-1][d];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}
 
 
0