結果
問題 | No.741 AscNumber(Easy) |
ユーザー | Feishi Li |
提出日時 | 2024-01-19 11:52:37 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,856 bytes |
コンパイル時間 | 4,755 ms |
コンパイル使用メモリ | 272,664 KB |
実行使用メモリ | 813,640 KB |
最終ジャッジ日時 | 2024-01-19 11:52:46 |
合計ジャッジ時間 | 7,384 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 2 ms
6,676 KB |
testcase_02 | AC | 2 ms
6,676 KB |
testcase_03 | AC | 2 ms
6,676 KB |
testcase_04 | AC | 2 ms
6,676 KB |
testcase_05 | AC | 2 ms
6,676 KB |
testcase_06 | AC | 2 ms
6,676 KB |
testcase_07 | AC | 2 ms
6,676 KB |
testcase_08 | AC | 2 ms
6,676 KB |
testcase_09 | AC | 2 ms
6,676 KB |
testcase_10 | AC | 2 ms
6,676 KB |
testcase_11 | AC | 2 ms
6,676 KB |
testcase_12 | AC | 2 ms
6,676 KB |
testcase_13 | AC | 2 ms
6,676 KB |
testcase_14 | AC | 2 ms
6,676 KB |
testcase_15 | AC | 2 ms
6,676 KB |
testcase_16 | AC | 2 ms
6,676 KB |
testcase_17 | AC | 2 ms
6,676 KB |
testcase_18 | AC | 2 ms
6,676 KB |
testcase_19 | AC | 2 ms
6,676 KB |
testcase_20 | AC | 4 ms
6,676 KB |
testcase_21 | AC | 3 ms
6,676 KB |
testcase_22 | AC | 4 ms
6,676 KB |
testcase_23 | AC | 4 ms
6,676 KB |
testcase_24 | AC | 2 ms
6,676 KB |
testcase_25 | AC | 3 ms
6,676 KB |
testcase_26 | AC | 4 ms
6,676 KB |
testcase_27 | AC | 3 ms
6,676 KB |
testcase_28 | AC | 3 ms
6,676 KB |
testcase_29 | AC | 3 ms
6,676 KB |
testcase_30 | AC | 4 ms
6,676 KB |
testcase_31 | AC | 3 ms
6,676 KB |
testcase_32 | AC | 2 ms
6,676 KB |
testcase_33 | AC | 4 ms
6,676 KB |
testcase_34 | AC | 5 ms
6,676 KB |
testcase_35 | MLE | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
ソースコード
#include <bits/stdc++.h> #include <bits/extc++.h> using i64 = long long; template <typename T, T MOD = 1000000007> struct Mint { inline static constexpr T mod = MOD; T v; Mint() : v(0) {} Mint(signed v) : v(v) {} Mint(long long t) { v = t % MOD; if (v < 0) v += MOD; } Mint pow(long long k) { Mint res(1), tmp(v); while (k) { if (k & 1) res *= tmp; tmp *= tmp; k >>= 1; } return res; } static Mint add_identity() { return Mint(0); } static Mint mul_identity() { return Mint(1); } Mint inv() { return pow(MOD - 2); } Mint &operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; } Mint &operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; } Mint &operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; } Mint &operator/=(Mint a) { return (*this) *= a.inv(); } Mint operator+(Mint a) const { return Mint(v) += a; } Mint operator-(Mint a) const { return Mint(v) -= a; } Mint operator*(Mint a) const { return Mint(v) *= a; } Mint operator/(Mint a) const { return Mint(v) /= a; } Mint operator+() const { return *this; } Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); } bool operator==(const Mint a) const { return v == a.v; } bool operator!=(const Mint a) const { return v != a.v; } static Mint comb(long long n, int k) { Mint num(1), dom(1); for (int i = 0; i < k; i++) { num *= Mint(n - i); dom *= Mint(i + 1); } return num / dom; } }; template <typename T, T MOD> std::ostream &operator<<(std::ostream &os, Mint<T, MOD> m) { os << m.v; return os; } using Z = Mint<i64>; void solve() { int n; std::cin >> n; std::string s = "1" + std::string(n, '0'); n = n + 1; const i64 NIL = -1; std::vector dp(n, std::vector(10, std::vector(2, std::vector(2, NIL)))); auto dfs = [&](auto self, int i, int cur, bool is_limit, bool is_asc) -> Z { if (i == n) { return is_asc; } auto &ndp = dp[i][cur][is_limit][is_asc]; if (ndp != NIL) { return ndp; } Z ans = 0; int up = is_limit ? s[i] - '0' : 9; for (int d = 0; d <= up; d++) { if (d >= cur) { ans += self(self, i + 1, d, is_limit and d == up, true); } } return ndp = ans.v; }; std::cout << dfs(dfs, 0, 0, true, true) << '\n'; } int main() { std::cin.tie(nullptr)->sync_with_stdio(false); solve(); return 0; }