結果

問題 No.1085 桁和の桁和
ユーザー Y17Y17
提出日時 2020-06-19 22:03:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 165,928 KB
実行使用メモリ 27,052 KB
最終ジャッジ日時 2023-09-30 06:04:55
合計ジャッジ時間 3,621 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
18,992 KB
testcase_01 AC 6 ms
19,108 KB
testcase_02 AC 7 ms
18,992 KB
testcase_03 AC 6 ms
19,012 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 6 ms
18,984 KB
testcase_07 AC 7 ms
19,040 KB
testcase_08 AC 7 ms
18,996 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 11 ms
19,956 KB
testcase_14 AC 20 ms
22,268 KB
testcase_15 AC 38 ms
25,788 KB
testcase_16 AC 37 ms
25,804 KB
testcase_17 AC 19 ms
22,304 KB
testcase_18 AC 14 ms
20,656 KB
testcase_19 AC 37 ms
25,092 KB
testcase_20 AC 37 ms
25,064 KB
testcase_21 AC 25 ms
22,872 KB
testcase_22 AC 32 ms
24,700 KB
testcase_23 AC 9 ms
19,480 KB
testcase_24 AC 6 ms
19,124 KB
testcase_25 AC 23 ms
22,444 KB
testcase_26 AC 42 ms
26,024 KB
testcase_27 AC 34 ms
24,588 KB
testcase_28 AC 43 ms
26,964 KB
testcase_29 AC 25 ms
23,308 KB
testcase_30 AC 24 ms
22,836 KB
testcase_31 AC 37 ms
25,736 KB
testcase_32 AC 27 ms
23,604 KB
testcase_33 AC 68 ms
26,984 KB
testcase_34 AC 68 ms
27,052 KB
testcase_35 AC 69 ms
26,984 KB
testcase_36 AC 70 ms
26,936 KB
testcase_37 AC 71 ms
26,924 KB
testcase_38 AC 73 ms
26,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

string s;
int d;
int memo[100010][20];

int dp(int i, int num){
	if(i == s.size()) return (num == 0 ? 9 : num) == d ? 1 : 0;
	if(memo[i][num] != -1) return memo[i][num];
	int ans = 0;
	if(s[i] != '?') ans = dp(i+1, (num*10+s[i]-'0') % 9);
	else{
		for(int k = 0;k < 10;k++){
			ans = (ans + dp(i+1, (num*10+k)% 9))%MOD;
		}
	}
	return memo[i][num] = ans;
}

signed main(){
	cin >> s >> d;

	memset(memo, -1, sizeof(memo));

	cout << dp(0, 0) << endl; 

	return 0;
}
0