結果
問題 | No.2734 Addition and Multiplication in yukicoder (Hard) |
ユーザー |
![]() |
提出日時 | 2024-04-19 22:48:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 515 ms / 5,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 2,695 ms |
コンパイル使用メモリ | 212,968 KB |
最終ジャッジ日時 | 2025-02-21 05:03:13 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/modint>using namespace std;using namespace atcoder;using mint=modint998244353;int main(){int n;cin>>n;vector<long long> a(n);for(int i=0;i<n;i++)cin>>a[i];vector<pair<string,long long>> srt(n);for(int i=0;i<n;i++){srt[i]={to_string(a[i]),a[i]};while(srt[i].first.length()<100)srt[i].first=srt[i].first+to_string(a[i]);srt[i].first=srt[i].first.substr(0,100);}sort(srt.begin(),srt.end());mint ans=0;vector<mint> pw(20);pw[0]=1;for(int i=0;i<19;i++)pw[i+1]=pw[i]*10;for(int i=0;i<n;i++){ans*=pw[to_string(srt[i].second).length()];ans+=srt[i].second;}cout<<ans.val()<<"\n";}