結果
問題 | No.2649 [Cherry 6th Tune C] Anthem Flower |
ユーザー | Today03 |
提出日時 | 2024-02-23 21:37:46 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 621 ms / 2,000 ms |
コード長 | 2,925 bytes |
コンパイル時間 | 1,927 ms |
コンパイル使用メモリ | 201,776 KB |
実行使用メモリ | 6,676 KB |
最終ジャッジ日時 | 2024-02-23 21:37:58 |
合計ジャッジ時間 | 8,293 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,676 KB |
testcase_01 | AC | 488 ms
6,676 KB |
testcase_02 | AC | 491 ms
6,676 KB |
testcase_03 | AC | 501 ms
6,676 KB |
testcase_04 | AC | 488 ms
6,676 KB |
testcase_05 | AC | 621 ms
6,676 KB |
testcase_06 | AC | 616 ms
6,676 KB |
testcase_07 | AC | 33 ms
6,676 KB |
testcase_08 | AC | 33 ms
6,676 KB |
testcase_09 | AC | 8 ms
6,676 KB |
testcase_10 | AC | 8 ms
6,676 KB |
testcase_11 | AC | 2 ms
6,676 KB |
testcase_12 | AC | 2 ms
6,676 KB |
testcase_13 | AC | 23 ms
6,676 KB |
testcase_14 | AC | 24 ms
6,676 KB |
testcase_15 | AC | 24 ms
6,676 KB |
testcase_16 | AC | 23 ms
6,676 KB |
testcase_17 | AC | 24 ms
6,676 KB |
testcase_18 | AC | 24 ms
6,676 KB |
testcase_19 | AC | 24 ms
6,676 KB |
testcase_20 | AC | 24 ms
6,676 KB |
testcase_21 | AC | 24 ms
6,676 KB |
testcase_22 | AC | 24 ms
6,676 KB |
testcase_23 | AC | 24 ms
6,676 KB |
testcase_24 | AC | 24 ms
6,676 KB |
testcase_25 | AC | 24 ms
6,676 KB |
testcase_26 | AC | 24 ms
6,676 KB |
testcase_27 | AC | 24 ms
6,676 KB |
testcase_28 | AC | 24 ms
6,676 KB |
testcase_29 | AC | 24 ms
6,676 KB |
testcase_30 | AC | 24 ms
6,676 KB |
testcase_31 | AC | 24 ms
6,676 KB |
testcase_32 | AC | 23 ms
6,676 KB |
testcase_33 | AC | 23 ms
6,676 KB |
testcase_34 | AC | 445 ms
6,676 KB |
ソースコード
#include <bits/stdc++.h> #ifdef LOCAL #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; struct dynamic_modint { long long value; static long long mod; static void set_mod(long long x) { mod = x; } static long long get_mod() { return mod; } dynamic_modint(long long x = 0) { if (x >= 0) { value = x % mod; } else { value = mod - (-x) % mod; } } dynamic_modint operator-() const { return dynamic_modint(-value); } dynamic_modint operator+() const { return dynamic_modint(*this); } dynamic_modint &operator+=(const dynamic_modint &other) { value += other.value; if (value >= mod) value -= mod; return *this; } dynamic_modint &operator-=(const dynamic_modint &other) { value += mod - other.value; if (value >= mod) value -= mod; return *this; } dynamic_modint &operator*=(const dynamic_modint other) { value = value * other.value % mod; return *this; } dynamic_modint &operator/=(dynamic_modint other) { (*this) *= other.inv(); return *this; } dynamic_modint operator+(const dynamic_modint &other) const { return dynamic_modint(*this) += other; } dynamic_modint operator-(const dynamic_modint &other) const { return dynamic_modint(*this) -= other; } dynamic_modint operator*(const dynamic_modint &other) const { return dynamic_modint(*this) *= other; } dynamic_modint operator/(const dynamic_modint &other) const { return dynamic_modint(*this) /= other; } dynamic_modint pow(long long x) const { dynamic_modint ret(1), mul(value); while (x) { if (x & 1) ret *= mul; mul *= mul; x >>= 1; } return ret; } dynamic_modint inv() const { return pow(mod - 2); } bool operator==(const dynamic_modint &other) const { return value == other.value; } bool operator!=(const dynamic_modint &other) const { return value != other.value; } friend ostream &operator<<(ostream &os, const dynamic_modint &x) { return os << x.value; } friend istream &operator>>(istream &is, dynamic_modint &x) { long long v; is >> v; x = dynamic_modint(v); return is; } }; long long dynamic_modint::mod = 998244353; using mint = dynamic_modint; int main() { int T; cin >> T; while (T--) { string N; int M; cin >> N >> M; mint::set_mod(2 * M); mint n = 0, tmp = 1; for (int i = (int)N.size() - 1; i >= 0; i--) { n += tmp * (N[i] - '0'); tmp *= 10; } n *= n + 1; cout << n.value / 2 % M << '\n'; } }