結果
問題 | No.2649 [Cherry 6th Tune C] Anthem Flower |
ユーザー | nono00 |
提出日時 | 2024-02-23 22:35:24 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,467 ms / 2,000 ms |
コード長 | 1,388 bytes |
コンパイル時間 | 2,924 ms |
コンパイル使用メモリ | 256,936 KB |
実行使用メモリ | 27,008 KB |
最終ジャッジ日時 | 2024-02-23 22:35:39 |
合計ジャッジ時間 | 14,348 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 709 ms
6,676 KB |
testcase_02 | AC | 683 ms
6,676 KB |
testcase_03 | AC | 687 ms
6,676 KB |
testcase_04 | AC | 708 ms
6,676 KB |
testcase_05 | AC | 1,463 ms
6,676 KB |
testcase_06 | AC | 1,467 ms
6,676 KB |
testcase_07 | AC | 74 ms
6,676 KB |
testcase_08 | AC | 74 ms
6,676 KB |
testcase_09 | AC | 16 ms
6,676 KB |
testcase_10 | AC | 16 ms
6,676 KB |
testcase_11 | AC | 3 ms
6,676 KB |
testcase_12 | AC | 2 ms
6,676 KB |
testcase_13 | AC | 153 ms
15,144 KB |
testcase_14 | AC | 173 ms
13,416 KB |
testcase_15 | AC | 152 ms
12,044 KB |
testcase_16 | AC | 151 ms
14,076 KB |
testcase_17 | AC | 154 ms
21,504 KB |
testcase_18 | AC | 151 ms
14,444 KB |
testcase_19 | AC | 155 ms
17,256 KB |
testcase_20 | AC | 157 ms
26,512 KB |
testcase_21 | AC | 163 ms
18,416 KB |
testcase_22 | AC | 153 ms
16,488 KB |
testcase_23 | AC | 154 ms
27,008 KB |
testcase_24 | AC | 154 ms
27,008 KB |
testcase_25 | AC | 153 ms
27,008 KB |
testcase_26 | AC | 152 ms
27,008 KB |
testcase_27 | AC | 155 ms
27,008 KB |
testcase_28 | AC | 167 ms
27,008 KB |
testcase_29 | AC | 154 ms
27,008 KB |
testcase_30 | AC | 154 ms
27,008 KB |
testcase_31 | AC | 154 ms
27,008 KB |
testcase_32 | AC | 154 ms
27,008 KB |
testcase_33 | AC | 148 ms
27,008 KB |
testcase_34 | AC | 460 ms
6,676 KB |
ソースコード
#include <bits/stdc++.h> struct P { int count = 0; int value = 0; }; void solve() { std::string s; int mod; std::cin >> s >> mod; std::vector<int> a; for (auto c: s) a.push_back(c - '0'); std::ranges::reverse(a); int n = a.size(); std::vector dp(n + 1, std::vector<P>(2)); dp[0][0].value = 0; dp[0][0].count = 1 % mod; int p10 = 1 % mod; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { for (int digit = 0; digit < 10; digit++) { int greater = 1; if (digit < a[i]) greater = 0; if (j == 0 && digit == a[i]) greater = 0; dp[i + 1][greater].count += dp[i][j].count; if (dp[i + 1][greater].count >= mod) dp[i + 1][greater].count -= mod; int diff = (long long)p10 * digit * dp[i][j].count % mod; diff += dp[i][j].value; if (diff >= mod) diff -= mod; dp[i + 1][greater].value += diff; if (dp[i + 1][greater].value >= mod) dp[i + 1][greater].value -= mod; } } p10 = (long long)p10 * 10 % mod; } std::cout << dp.back()[0].value << '\n'; } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; std::cin >> t; while (t--) solve(); }