結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー Ricky_ponRicky_pon
提出日時 2021-03-05 22:08:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 3,000 ms
コード長 1,804 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 197,708 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 09:38:12
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 4 ms
6,944 KB
testcase_34 AC 6 ms
6,940 KB
testcase_35 AC 6 ms
6,940 KB
testcase_36 AC 6 ms
6,944 KB
testcase_37 AC 6 ms
6,944 KB
testcase_38 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

using namespace atcoder;
using mint = modint1000000007;

mint dp[10010][2][3][3];

int f(int k, int x) { return min(2, k + __builtin_ctz(x)); }

int g(int l, int x) { return min(2, l + (x == 5)); }

int main() {
    string s;
    cin >> s;
    int n = s.size();

    rep(i, n) {
        if (i == 0) dp[i][0][f(0, s[i] - '0')][g(0, s[i] - '0')] = 1;
        int mx = (i == 0 ? s[i] - '0' - 1 : 9);
        For(x, 1, mx + 1)++ dp[i][1][f(0, x)][g(0, x)];
    }
    For(i, 1, n) rep(j, 2) rep(k, 3) rep(l, 3) if (dp[i - 1][j][k][l] != 0) {
        int mx = (j ? 9 : s[i] - '0');
        For(x, 1, mx + 1) {
            dp[i][j | (x < s[i] - '0')][f(k, x)][g(l, x)] += dp[i - 1][j][k][l];
        }
    }
    printf("%u\n", (dp[n - 1][0][2][2] + dp[n - 1][1][2][2]).val());
}
0