結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー 👑 hitonanodehitonanode
提出日時 2024-04-19 22:35:18
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 548 ms / 5,000 ms
コード長 1,224 bytes
コンパイル時間 1,314 ms
コンパイル使用メモリ 115,948 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 22:35:30
合計ジャッジ時間 10,371 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 234 ms
5,376 KB
testcase_18 AC 226 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 533 ms
5,376 KB
testcase_23 AC 518 ms
5,376 KB
testcase_24 AC 535 ms
5,376 KB
testcase_25 AC 548 ms
5,376 KB
testcase_26 AC 529 ms
5,376 KB
testcase_27 AC 430 ms
5,376 KB
testcase_28 AC 517 ms
5,376 KB
testcase_29 AC 511 ms
5,376 KB
testcase_30 AC 377 ms
5,376 KB
testcase_31 AC 510 ms
5,376 KB
testcase_32 AC 473 ms
5,376 KB
testcase_33 AC 250 ms
5,376 KB
testcase_34 AC 351 ms
5,376 KB
testcase_35 AC 144 ms
5,376 KB
testcase_36 AC 147 ms
5,376 KB
testcase_37 AC 302 ms
5,376 KB
testcase_38 AC 265 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using lint = long long;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template <class IStream, class T> IStream &operator>>(IStream &is, std::vector<T> &vec) { for (auto &v : vec) is >> v; return is; }

#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<lint> A(N);
    cin >> A;

    vector<__int128> pow10s(20, 1);
    FOR(i, 1, 20) pow10s[i] = pow10s[i - 1] * 10;

    sort(A.begin(), A.end(), [&](lint l, lint r) {
        const int lsz = to_string(l).size(), rsz = to_string(r).size();
        return pow10s.at(lsz) * r + l > pow10s.at(rsz) * l + r;
        // return (pow10s.at(lsz) * l) * pow10s.at(rsz) + r < (pow10s.at(rsz) * r) * pow10s.at(lsz) + l;
        // if (lsz < rsz) return false;
        // return l < r;
        // if (to_string(l).size() == to_string(r).size()) return l < r;
    });

    mint ret = 0;

    for (lint a : A) {
        int sz = to_string(a).size();
        ret = ret * mint(10).pow(sz) + a;
    }

    cout << ret.val() << '\n';
}
0