結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー AngrySadEightAngrySadEight
提出日時 2024-03-18 23:55:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,074 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 11,140 KB
最終ジャッジ日時 2024-03-18 23:55:29
合計ジャッジ時間 5,562 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 1 ms
6,676 KB
testcase_05 AC 1 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 1 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 107 ms
11,140 KB
testcase_18 AC 115 ms
11,140 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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<long double> pow_d(19);
    pow_d[0] = 1;
    for (ll i = 0; i < 18; i++){
        pow_d[i + 1] = pow_d[i] * 10;
    }
    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;
    }
    vector<pair<long double, ll>> vec(N);
    for (ll i = 0; i < N; i++){
        ll len = to_string(A[i]).size();
        vec[i].first = (long double)(A[i]) / (pow_10[len] - 1);
        vec[i].second = A[i];
    }
    sort(vec.begin(), vec.end());
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll as_val = vec[i].second;
        ll len = to_string(as_val).size();
        ans = (ans * pow_10[len]) % mod;
        ans = (ans + as_val % mod) % mod;
    }
    cout << ans << endl;
}
0