結果
問題 |
No.2734 Addition and Multiplication in yukicoder (Hard)
|
ユーザー |
![]() |
提出日時 | 2024-04-19 22:35:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 574 ms / 5,000 ms |
コード長 | 1,224 bytes |
コンパイル時間 | 1,316 ms |
コンパイル使用メモリ | 113,704 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 16:12:50 |
合計ジャッジ時間 | 10,772 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; using lint = long long; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define REP(i, n) FOR(i,0,n) template <class IStream, class T> IStream &operator>>(IStream &is, std::vector<T> &vec) { for (auto &v : vec) is >> v; return is; } #include <atcoder/modint> using mint = atcoder::modint998244353; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; cin >> N; vector<lint> A(N); cin >> A; vector<__int128> pow10s(20, 1); FOR(i, 1, 20) pow10s[i] = pow10s[i - 1] * 10; sort(A.begin(), A.end(), [&](lint l, lint r) { const int lsz = to_string(l).size(), rsz = to_string(r).size(); return pow10s.at(lsz) * r + l > pow10s.at(rsz) * l + r; // return (pow10s.at(lsz) * l) * pow10s.at(rsz) + r < (pow10s.at(rsz) * r) * pow10s.at(lsz) + l; // if (lsz < rsz) return false; // return l < r; // if (to_string(l).size() == to_string(r).size()) return l < r; }); mint ret = 0; for (lint a : A) { int sz = to_string(a).size(); ret = ret * mint(10).pow(sz) + a; } cout << ret.val() << '\n'; }