結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー butsurizukibutsurizuki
提出日時 2024-04-19 21:38:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 902 ms / 5,000 ms
コード長 642 bytes
コンパイル時間 3,687 ms
コンパイル使用メモリ 283,312 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 21:39:02
合計ジャッジ時間 17,041 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 350 ms
6,940 KB
testcase_18 AC 366 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 863 ms
6,944 KB
testcase_23 AC 839 ms
6,940 KB
testcase_24 AC 872 ms
6,944 KB
testcase_25 AC 902 ms
6,944 KB
testcase_26 AC 879 ms
6,944 KB
testcase_27 AC 733 ms
6,940 KB
testcase_28 AC 866 ms
6,944 KB
testcase_29 AC 825 ms
6,944 KB
testcase_30 AC 637 ms
6,944 KB
testcase_31 AC 830 ms
6,940 KB
testcase_32 AC 766 ms
6,940 KB
testcase_33 AC 426 ms
6,940 KB
testcase_34 AC 606 ms
6,944 KB
testcase_35 AC 259 ms
6,944 KB
testcase_36 AC 274 ms
6,940 KB
testcase_37 AC 512 ms
6,940 KB
testcase_38 AC 455 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define mod 998244353

using namespace std;

bool comp(const long long a,const long long b){
  string sa=to_string(a);
  string sb=to_string(b);
  string ab=sa+sb;
  string ba=sb+sa;
  return (ab<ba);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<long long> p10(20);
  p10[0]=1;
  for(int i=1;i<20;i++){
    p10[i]=(p10[i-1]*10)%mod;
  }

  int n;
  cin >> n;
  vector<long long> a(n);
  for(auto &nx : a){cin >> nx;}
  sort(a.begin(),a.end(),comp);
  long long x=0;
  for(auto &nx : a){
    x*=p10[to_string(nx).size()]; x%=mod;
    x+=nx; x%=mod;
  }
  cout << x << "\n";
  return 0;
}
0