結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
コンテスト
ユーザー detteiuu
提出日時 2025-11-09 04:38:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,587 ms / 5,000 ms
+ 131µs
コード長 681 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 235 ms
コンパイル使用メモリ 95,984 KB
実行使用メモリ 132,736 KB
最終ジャッジ日時 2026-07-16 10:06:09
合計ジャッジ時間 33,644 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from functools import cmp_to_key

MOD = 998244353

N = int(input())
A = list(map(int, input().split()))

def compare(left, right):
    L, R = str(left), str(right)
    for i in range(len(L)+len(R)):
        l, r = -1, -1
        if i < len(L):
            l = int(L[i])
        else:
            l = int(R[i-len(L)])
        if i < len(R):
            r = int(R[i])
        else:
            r = int(L[i-len(R)])
        if l < r:
            return -1
        if l > r:
            return 1
    return 0

A.sort(key=cmp_to_key(compare))
POW = [1]
for _ in range(20):
    POW.append(POW[-1]*10%MOD)
ans = 0
for a in A:
    l = len(str(a))
    ans = ((ans*POW[l])+a)%MOD

print(ans)
0