結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー kwm_tkwm_t
提出日時 2021-03-06 18:58:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 456 ms / 3,000 ms
コード長 2,412 bytes
コンパイル時間 3,796 ms
コンパイル使用メモリ 225,148 KB
実行使用メモリ 316,160 KB
最終ジャッジ日時 2024-04-17 06:43:54
合計ジャッジ時間 14,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
316,028 KB
testcase_01 AC 169 ms
316,068 KB
testcase_02 AC 171 ms
315,968 KB
testcase_03 AC 170 ms
316,000 KB
testcase_04 AC 169 ms
315,944 KB
testcase_05 AC 171 ms
315,904 KB
testcase_06 AC 168 ms
316,032 KB
testcase_07 AC 170 ms
315,944 KB
testcase_08 AC 170 ms
316,020 KB
testcase_09 AC 169 ms
315,856 KB
testcase_10 AC 171 ms
316,152 KB
testcase_11 AC 170 ms
316,160 KB
testcase_12 AC 171 ms
316,044 KB
testcase_13 AC 169 ms
316,060 KB
testcase_14 AC 170 ms
316,156 KB
testcase_15 AC 172 ms
316,160 KB
testcase_16 AC 172 ms
315,984 KB
testcase_17 AC 172 ms
316,056 KB
testcase_18 AC 170 ms
316,016 KB
testcase_19 AC 171 ms
316,160 KB
testcase_20 AC 170 ms
316,032 KB
testcase_21 AC 170 ms
315,948 KB
testcase_22 AC 171 ms
316,120 KB
testcase_23 AC 170 ms
315,964 KB
testcase_24 AC 169 ms
316,096 KB
testcase_25 AC 170 ms
316,032 KB
testcase_26 AC 226 ms
315,904 KB
testcase_27 AC 221 ms
316,124 KB
testcase_28 AC 170 ms
315,904 KB
testcase_29 AC 191 ms
316,036 KB
testcase_30 AC 231 ms
316,076 KB
testcase_31 AC 227 ms
315,972 KB
testcase_32 AC 254 ms
316,124 KB
testcase_33 AC 282 ms
316,032 KB
testcase_34 AC 351 ms
316,160 KB
testcase_35 AC 353 ms
315,904 KB
testcase_36 AC 368 ms
315,904 KB
testcase_37 AC 456 ms
315,996 KB
testcase_38 AC 342 ms
315,904 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が出たかどうか
//mint f(int i, int j, int k, int l, int m) {
	//return dp[ni][nj][nk][nl][];
//}
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';
							//一致->一致
							{
								int n = num;
								int ni = i + 1;
								int nj = 0;
								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 == num) && (1 != nl)) {
									nm = min(1, m + 1);
								}
								dp[ni][nj][nk][nl][nm] += dp[i][j][k][l][m];
							}
							//一致->不一致
							rep(n, num) {
								int ni = i + 1;
								int nj = 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];
							}
						}
						else {
							//不一致->不一致
							rep(n, 10) {
								int ni = i + 1;
								int nj = 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];
							}
						}
					}
				}
			}
		}
	}

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