結果
| 問題 |
No.2734 Addition and Multiplication in yukicoder (Hard)
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-11-09 04:38:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,615 ms / 5,000 ms |
| コード長 | 681 bytes |
| コンパイル時間 | 4,009 ms |
| コンパイル使用メモリ | 81,992 KB |
| 実行使用メモリ | 130,372 KB |
| 最終ジャッジ日時 | 2025-11-09 04:39:49 |
| 合計ジャッジ時間 | 47,466 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
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)
detteiuu