結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー kwm_tkwm_t
提出日時 2021-03-06 19:04:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 637 ms / 3,000 ms
コード長 1,615 bytes
コンパイル時間 3,701 ms
コンパイル使用メモリ 224,216 KB
実行使用メモリ 316,288 KB
最終ジャッジ日時 2024-04-17 06:47:11
合計ジャッジ時間 10,860 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
316,072 KB
testcase_01 AC 84 ms
316,088 KB
testcase_02 AC 91 ms
316,060 KB
testcase_03 AC 84 ms
316,160 KB
testcase_04 AC 85 ms
316,076 KB
testcase_05 AC 83 ms
315,940 KB
testcase_06 AC 83 ms
315,904 KB
testcase_07 AC 82 ms
316,288 KB
testcase_08 AC 83 ms
316,032 KB
testcase_09 AC 84 ms
315,996 KB
testcase_10 AC 84 ms
316,052 KB
testcase_11 AC 84 ms
315,940 KB
testcase_12 AC 84 ms
316,160 KB
testcase_13 AC 84 ms
316,160 KB
testcase_14 AC 85 ms
316,104 KB
testcase_15 AC 85 ms
315,980 KB
testcase_16 AC 87 ms
316,124 KB
testcase_17 AC 87 ms
316,032 KB
testcase_18 AC 87 ms
316,032 KB
testcase_19 AC 89 ms
315,952 KB
testcase_20 AC 88 ms
316,040 KB
testcase_21 AC 86 ms
316,096 KB
testcase_22 AC 89 ms
316,048 KB
testcase_23 AC 86 ms
316,160 KB
testcase_24 AC 86 ms
316,124 KB
testcase_25 AC 86 ms
316,032 KB
testcase_26 AC 85 ms
316,016 KB
testcase_27 AC 87 ms
316,112 KB
testcase_28 AC 90 ms
316,032 KB
testcase_29 AC 96 ms
316,160 KB
testcase_30 AC 122 ms
316,136 KB
testcase_31 AC 113 ms
316,064 KB
testcase_32 AC 169 ms
316,124 KB
testcase_33 AC 275 ms
316,148 KB
testcase_34 AC 511 ms
315,996 KB
testcase_35 AC 516 ms
316,136 KB
testcase_36 AC 517 ms
315,992 KB
testcase_37 AC 637 ms
316,080 KB
testcase_38 AC 391 ms
316,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include "atcoder/all"
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
mint dp[100002][2][100][2][2];
//桁,一致or不一致,mod100,0始まりかどうか,0が出たかどうか
void f(int i, int j, int k, int l, int m, int n, int nj) {
	int ni = i + 1;
	int nk = (k * n) % 100;
	if (1 == l) {
		nk = n;
	}
	int nl = 0;
	if ((1 == l) && (0 == n)) {
		nl = 1;
	}
	int nm = m;
	if ((0 == n) && (1 != nl)) {
		nm = min(1, m + 1);
	}
	dp[ni][nj][nk][nl][nm] += dp[i][j][k][l][m];
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string N;
	cin >> N;
	dp[0][0][0][1][0] = 1;
	rep(i, N.size()) {
		//配るdp
		rep(j, 2) {
			rep(k, 100) {
				rep(l, 2) {
					rep(m, 2) {
						if (0 == j) {
							int num = N[i] - '0';
							//一致->一致
							f(i, j, k, l, m, num, 0);
							//一致->不一致
							rep(n, num) {
								f(i, j, k, l, m, n, 1);
							}
						}
						else {
							//不一致->不一致
							rep(n, 10) {
								f(i, j, k, l, m, n, 1);
							}
						}
					}
				}
			}
		}
	}

	mint ans = 0;
	rep(i, 2) {
		ans += dp[N.size()][i][0][0][0];
	}
	cout << ans.val() << endl;
	return 0;
}
0