結果

問題 No.1085 桁和の桁和
ユーザー kanra824kanra824
提出日時 2020-06-19 22:06:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,831 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 171,468 KB
実行使用メモリ 13,420 KB
最終ジャッジ日時 2023-09-30 06:10:23
合計ジャッジ時間 3,457 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 11 ms
6,712 KB
testcase_15 AC 25 ms
11,700 KB
testcase_16 AC 25 ms
11,696 KB
testcase_17 AC 12 ms
6,932 KB
testcase_18 AC 7 ms
5,104 KB
testcase_19 AC 23 ms
10,968 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 15 ms
7,980 KB
testcase_22 AC 20 ms
10,148 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 13 ms
7,504 KB
testcase_26 AC 26 ms
11,920 KB
testcase_27 AC 21 ms
10,136 KB
testcase_28 AC 30 ms
13,248 KB
testcase_29 AC 16 ms
8,228 KB
testcase_30 AC 15 ms
7,956 KB
testcase_31 AC 26 ms
11,764 KB
testcase_32 AC 17 ms
8,828 KB
testcase_33 AC 40 ms
13,300 KB
testcase_34 AC 39 ms
13,364 KB
testcase_35 AC 39 ms
13,320 KB
testcase_36 AC 39 ms
13,420 KB
testcase_37 AC 39 ms
13,260 KB
testcase_38 AC 39 ms
13,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string t; cin >> t;
  int n = SZ(t);
  int d; cin >> d;
  if(d == 0) {
    bool ok = true;
    REP(i, n) {
      ok &= t[i] == '?' || t[i] == '0';
    }
    cout << ok << endl;
    return 0;
  }
  ll now = 1;

  vvll dp(n+1, vll(9, 0));
  dp[0][0] = 1;

  REP(i, n) {
    REP(j, 9) {
      if(t[i] == '?') {
        REP(k, 10) {
          (dp[i+1][(j+k)%9] += dp[i][j]) %= MOD;
        }
      } else {
        (dp[i+1][(j+(t[i]-'0'))%9] += dp[i][j]) %= MOD;
      }
    }
  }

  cout << dp[n][d%9] << endl;

}






0