結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー ooaiu
提出日時 2025-03-28 17:19:13
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 266 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 4,909 ms
コンパイル使用メモリ 286,728 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2025-03-28 17:19:25
合計ジャッジ時間 9,419 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) (void(0))
#endif
void run_case();
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while (T--) run_case();
    return 0;
}
void run_case() {
    int N;
    cin >> N;
    vector<string> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end(), [](const auto&a, const auto&b) {
        if(a.size() == b.size()) return a < b;
        string A = a + b;
        string B = b + a;
        return A < B;
    });
    const int md = 998244353;
    ll ans = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < A[i].size(); j++) {
            ans *= 10;
            ans += A[i][j] - '0';
            ans %= md;
        }
    }
    cout << ans << endl;
}
0