結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー GGanari
提出日時 2024-04-20 00:08:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 348 ms / 5,000 ms
コード長 874 bytes
コンパイル時間 2,480 ms
コンパイル使用メモリ 207,552 KB
最終ジャッジ日時 2025-02-21 05:53:23
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define INF 1000000001LL
#define LNF 1000000000000000001LL
#define MOD 998244353LL
#define MAX 1005
#define long long long
#define all(x) x.begin(),x.end()
using namespace std;


int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);
    
    
    int n;
    cin >> n;

    vector<pair<string,long>> arr;

    for(int i = 0; i<n; i++)
    {
        long x;
        cin >> x;
        string s;
        string strX = to_string(x);
        for(int j = 0; j < 50; j++)
            s.push_back(strX[j%strX.size()]);
        arr.push_back({s,x});
    }
    sort(all(arr));
    long res = 0;
    for(int i = 0; i<n; i++)
    {
        long x = arr[i].second;
        while(x)
        {
            res*=10;
            res%=MOD;
            x/=10;
        }
        res+=arr[i].second;
        res%=MOD;
    }
    cout << res << endl;
    return 0;
}
0