結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー AngrySadEightAngrySadEight
提出日時 2024-03-18 14:14:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,172 ms / 5,000 ms
コード長 818 bytes
コンパイル時間 1,298 ms
コンパイル使用メモリ 87,972 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-03-18 14:15:11
合計ジャッジ時間 18,767 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 346 ms
11,136 KB
testcase_18 AC 353 ms
11,136 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 1,128 ms
17,408 KB
testcase_23 AC 1,105 ms
17,408 KB
testcase_24 AC 1,139 ms
17,408 KB
testcase_25 AC 1,172 ms
17,408 KB
testcase_26 AC 1,075 ms
17,408 KB
testcase_27 AC 920 ms
15,488 KB
testcase_28 AC 1,110 ms
16,768 KB
testcase_29 AC 1,072 ms
16,640 KB
testcase_30 AC 785 ms
14,336 KB
testcase_31 AC 1,103 ms
17,024 KB
testcase_32 AC 985 ms
15,728 KB
testcase_33 AC 518 ms
11,300 KB
testcase_34 AC 765 ms
13,524 KB
testcase_35 AC 295 ms
8,352 KB
testcase_36 AC 294 ms
8,672 KB
testcase_37 AC 666 ms
12,312 KB
testcase_38 AC 563 ms
11,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

bool comp(string a, string b) { return a + b < b + a; }

ll mod = 998244353;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<string> As(N);
    for (ll i = 0; i < N; i++) {
        As[i] = to_string(A[i]);
    }
    sort(As.begin(), As.end(), comp);
    vector<ll> pow_10(19);
    pow_10[0] = 1;
    for (ll i = 0; i < 18; i++) {
        pow_10[i + 1] = (pow_10[i] * 10LL) % mod;
    }
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll as_val = stoll(As[i]);
        ll len = As[i].size();
        ans = (ans * pow_10[len]) % mod;
        ans = (ans + as_val % mod) % mod;
    }
    cout << ans << endl;
}
0