結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー e869120e869120
提出日時 2021-03-05 21:28:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 3,000 ms
コード長 1,040 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 84,824 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-16 08:49:25
合計ジャッジ時間 3,291 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 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 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 20 ms
5,376 KB
testcase_31 AC 25 ms
5,376 KB
testcase_32 AC 47 ms
6,912 KB
testcase_33 AC 115 ms
11,264 KB
testcase_34 AC 223 ms
18,816 KB
testcase_35 AC 228 ms
19,072 KB
testcase_36 AC 228 ms
19,200 KB
testcase_37 AC 232 ms
18,944 KB
testcase_38 AC 226 ms
19,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

string S;
long long mod = 1000000007;
long long dp1[10009][100];
long long dp2[10009][100];

int main() {
	cin >> S;
	for (int i = S.size() - 1; i >= 0; i--) {
		for (int j = 0; j <= 99; j++) {
			// 前から引き継ぐ場合
			for (int k = 1; k <= 9; k++) {
				dp1[i][j * k % 100] += dp1[i + 1][j];
				if (k < (S[S.size() - 1 - i] - '0')) dp1[i][j * k % 100] += dp2[i + 1][j];
				if (k == (S[S.size() - 1 - i] - '0')) dp2[i][j * k % 100] += dp2[i + 1][j];
				dp1[i][j * k % 100] %= mod;
				dp2[i][j * k % 100] %= mod;
			}
		}
		// 新たな桁の場合
		for (int k = 1; k <= 9; k++) {
			if (i != S.size() - 1) dp1[i][k] += 1;
			else if (k < (S[S.size() - 1 - i] - '0')) dp1[i][k] += 1;
			else if (k == (S[S.size() - 1 - i] - '0')) dp2[i][k] += 1;
		}
	}

	long long Answer = dp1[0][0] + dp2[0][0];
	cout << Answer % mod << endl;
	return 0;
}
0