結果

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

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
long long get(long long n){
	return to_string(n).size();
}
int main(){
	
	int n;
	cin>>n;
	vector<pair<long long,long long>> a(n);
	rep(i,n){
		long long t;
		cin>>t;
		a[i] =make_pair(get(t),t);
	}
	
	sort(a.begin(),a.end(),[&](pair<long long,long long> x,pair<long long,long long> y){
		__int128 X = x.second,Y = y.second;
		rep(i,x.first)Y *= 10;
		rep(i,y.first)X *= 10;
		X -= x.second,Y -= y.second;
		return X<Y;
		
	});
	mint ans = 0;
	rep(i,n){
		rep(j,a[i].first)ans *= 10;
		ans += a[i].second;
	}
	cout<<ans.val()<<endl;
	
	return 0;
}
0