結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー kaichou243kaichou243
提出日時 2024-04-19 21:39:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 606 ms / 5,000 ms
コード長 750 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 206,432 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-04-19 21:39:25
合計ジャッジ時間 11,222 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 169 ms
6,944 KB
testcase_18 AC 194 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 571 ms
9,020 KB
testcase_23 AC 567 ms
8,764 KB
testcase_24 AC 566 ms
9,868 KB
testcase_25 AC 606 ms
10,272 KB
testcase_26 AC 555 ms
9,228 KB
testcase_27 AC 461 ms
8,948 KB
testcase_28 AC 547 ms
9,892 KB
testcase_29 AC 544 ms
9,884 KB
testcase_30 AC 366 ms
8,768 KB
testcase_31 AC 541 ms
8,764 KB
testcase_32 AC 502 ms
8,684 KB
testcase_33 AC 248 ms
6,940 KB
testcase_34 AC 357 ms
9,228 KB
testcase_35 AC 143 ms
6,944 KB
testcase_36 AC 129 ms
6,940 KB
testcase_37 AC 315 ms
9,040 KB
testcase_38 AC 264 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
void mpl(ll& x,ll y){
	x+=y;
	if(x>998244353) x-=998244353;
}
int digit(ll x){
	int ret=0;
	while(x) x/=10,ret++;
	return ret;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end(),[](ll x,ll y)->bool{
		__int128_t X=x,Y=y;
		int dx=digit(x),dy=digit(y);
		for(int i=0;i<dy;i++) X*=10;
		for(int i=0;i<dx;i++) Y*=10;
		X+=y;
		Y+=x;
		return X<Y;
	});
	string s;
	for(int i=0;i<n;i++){
		string t=to_string(a[i]);
		s+=t;
	}
	reverse(s.begin(),s.end());
	ll ans=0,pw=1;
	for(int i=0;i<s.size();i++){
		mpl(ans,(pw*(s[i]-'0'))%998244353);
		pw=(pw*10)%998244353;
	}
	cout<<ans<<endl;
}
0