結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー otoshigootoshigo
提出日時 2024-04-19 23:52:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 520 ms / 5,000 ms
コード長 1,007 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 205,500 KB
実行使用メモリ 50,404 KB
最終ジャッジ日時 2024-04-19 23:53:03
合計ジャッジ時間 11,267 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 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 1 ms
5,376 KB
testcase_12 AC 2 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 1 ms
5,376 KB
testcase_17 AC 240 ms
19,212 KB
testcase_18 AC 242 ms
20,948 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 508 ms
50,140 KB
testcase_23 AC 485 ms
50,404 KB
testcase_24 AC 487 ms
50,280 KB
testcase_25 AC 485 ms
50,396 KB
testcase_26 AC 462 ms
50,272 KB
testcase_27 AC 455 ms
40,504 KB
testcase_28 AC 520 ms
47,064 KB
testcase_29 AC 466 ms
46,176 KB
testcase_30 AC 390 ms
34,448 KB
testcase_31 AC 469 ms
48,628 KB
testcase_32 AC 471 ms
43,096 KB
testcase_33 AC 261 ms
24,920 KB
testcase_34 AC 373 ms
33,820 KB
testcase_35 AC 168 ms
15,724 KB
testcase_36 AC 162 ms
15,904 KB
testcase_37 AC 321 ms
30,152 KB
testcase_38 AC 263 ms
26,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const int MOD=998244353;

bool compare(string&s1,string&s2){
    return(s1+s2<s2+s1);
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    srand(time(NULL));
    int N;
    cin>>N;
    vector<string>S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end(),compare);
    string ans="";
    for(int i=0;i<N;i++)ans+=S[i];
    int L=ans.size();
    vector<ll>ten(L);
    ten[0]=1;
    for(int i=1;i<L;i++)ten[i]=10*ten[i-1]%MOD;
    ll val=0;
    for(int i=0;i<L;i++){
        val+=(ans[i]-'0')*ten[L-1-i]%MOD;
        val%=MOD;
    }
    cout<<val<<"\n";
}
0