結果

問題 No.1085 桁和の桁和
ユーザー 沙耶花沙耶花
提出日時 2020-06-19 21:54:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 2,151 ms
コンパイル使用メモリ 202,972 KB
実行使用メモリ 10,284 KB
最終ジャッジ日時 2023-09-30 06:04:13
合計ジャッジ時間 3,625 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 31 ms
9,924 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 9 ms
5,756 KB
testcase_15 AC 20 ms
9,140 KB
testcase_16 AC 19 ms
9,228 KB
testcase_17 AC 10 ms
5,956 KB
testcase_18 AC 6 ms
4,428 KB
testcase_19 AC 18 ms
8,388 KB
testcase_20 AC 19 ms
8,604 KB
testcase_21 AC 12 ms
6,536 KB
testcase_22 AC 16 ms
8,132 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 10 ms
6,228 KB
testcase_26 AC 21 ms
9,456 KB
testcase_27 AC 17 ms
8,072 KB
testcase_28 AC 25 ms
10,160 KB
testcase_29 AC 13 ms
6,752 KB
testcase_30 AC 11 ms
6,608 KB
testcase_31 AC 22 ms
9,136 KB
testcase_32 AC 15 ms
7,024 KB
testcase_33 AC 34 ms
10,284 KB
testcase_34 AC 33 ms
10,236 KB
testcase_35 AC 31 ms
10,252 KB
testcase_36 AC 31 ms
10,236 KB
testcase_37 AC 35 ms
10,180 KB
testcase_38 AC 33 ms
10,192 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){
		bool f = true;
		for(int i=0;i<S.size();i++){
			if(S[i]!='0'&&S[i]!='?'){
				f=false;
			}
		}
		if(f)cout<<1<<endl;
		else cout<<0<<endl;
	}
	else cout<<dp.back()[D%9]<<endl;
	
	return 0;
}
0