結果

問題 No.1085 桁和の桁和
ユーザー 沙耶花沙耶花
提出日時 2020-06-19 21:56:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 203,088 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2023-09-30 06:04:25
合計ジャッジ時間 3,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 11 ms
5,956 KB
testcase_15 AC 23 ms
9,136 KB
testcase_16 AC 22 ms
9,128 KB
testcase_17 AC 11 ms
5,968 KB
testcase_18 AC 6 ms
4,428 KB
testcase_19 AC 19 ms
8,388 KB
testcase_20 AC 19 ms
8,724 KB
testcase_21 AC 13 ms
6,784 KB
testcase_22 AC 18 ms
8,164 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 11 ms
6,248 KB
testcase_26 AC 21 ms
9,388 KB
testcase_27 AC 17 ms
8,080 KB
testcase_28 AC 24 ms
10,240 KB
testcase_29 AC 13 ms
6,760 KB
testcase_30 AC 11 ms
6,540 KB
testcase_31 AC 21 ms
9,420 KB
testcase_32 AC 14 ms
7,372 KB
testcase_33 AC 32 ms
10,232 KB
testcase_34 AC 31 ms
10,184 KB
testcase_35 AC 32 ms
10,164 KB
testcase_36 AC 31 ms
10,188 KB
testcase_37 AC 31 ms
10,236 KB
testcase_38 AC 31 ms
10,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000LL



int main(){
	
	string S;
	cin>>S;
	
	vector<vector<int>> dp(S.size()+1,vector<int>(9,0));
	dp[0][0] = 1;
	
	for(int i=0;i<S.size();i++){
		for(int j=0;j<9;j++){
			if(dp[i][j]==0)continue;
			char c = S[i];
			if(c=='?'){
				for(int k=0;k<10;k++){
					int nj = (j * 10 + k)%9;
					dp[i+1][nj] = mod(dp[i+1][nj] + dp[i][j]);
				}
			}
			else{
				int t = c-'0';
				dp[i+1][(j*10 + t)%9] = mod(dp[i+1][(j*10+t)%9] + dp[i][j]);
			}
		}
	}
	
	int D;
	cin>>D;
	if(D==0){
		cout<<0<<endl;
	}
	else cout<<dp.back()[D%9]<<endl;
	
	return 0;
}
0