結果

問題 No.1085 桁和の桁和
ユーザー 夜
提出日時 2020-07-18 06:06:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 94,012 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-24 10:12:33
合計ジャッジ時間 2,928 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 65 ms
11,392 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 18 ms
6,656 KB
testcase_15 AC 39 ms
10,368 KB
testcase_16 AC 38 ms
10,240 KB
testcase_17 AC 18 ms
6,784 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 34 ms
9,600 KB
testcase_20 AC 34 ms
9,728 KB
testcase_21 AC 22 ms
7,424 KB
testcase_22 AC 32 ms
9,216 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 20 ms
7,040 KB
testcase_26 AC 39 ms
10,752 KB
testcase_27 AC 32 ms
9,216 KB
testcase_28 AC 45 ms
11,648 KB
testcase_29 AC 24 ms
7,680 KB
testcase_30 AC 22 ms
7,296 KB
testcase_31 AC 37 ms
10,240 KB
testcase_32 AC 26 ms
8,320 KB
testcase_33 AC 68 ms
11,520 KB
testcase_34 AC 68 ms
11,520 KB
testcase_35 AC 66 ms
11,520 KB
testcase_36 AC 68 ms
11,648 KB
testcase_37 AC 66 ms
11,648 KB
testcase_38 AC 66 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long dp[10][100010] = { 0 };
int main() {
	string s;
	cin >> s;
	dp[0][0] = 1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '?') {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					int d = (j + k) / 10 + (j + k) % 10;
					d = d / 10 + d % 10;
					d = d / 10 + d % 10;
					dp[d][i + 1] += dp[j][i];
					dp[d][i + 1] %= 1000000007;
				}
			}
		}
		else {
			for (int j = 0; j < 10; j++) {
				int d = (j + int(s[i] - '0')) / 10 + (j + int(s[i] - '0')) % 10;
				d = d / 10 + d % 10;
				d = d / 10 + d % 10;
				dp[d][i + 1] += dp[j][i];
				dp[d][i + 1] %= 1000000007;
			}
		}
	}
	int di;
	cin >> di;
	cout << dp[di][s.size()] << endl;
	return 0;
}
0