結果
問題 |
No.2734 Addition and Multiplication in yukicoder (Hard)
|
ユーザー |
![]() |
提出日時 | 2024-04-19 22:06:03 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 750 bytes |
コンパイル時間 | 5,223 ms |
コンパイル使用メモリ | 77,288 KB |
実行使用メモリ | 77,976 KB |
最終ジャッジ日時 | 2024-10-11 15:18:32 |
合計ジャッジ時間 | 23,606 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 WA * 35 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); Arrays.sort(sa); long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = Long.parseLong(sa[i]); } br.close(); int mod = 998244353; long[] b = new long[20]; b[0] = 1; for (int i = 1; i < b.length; i++) { b[i] = b[i - 1] * 10; b[i] %= mod; } long ans = 0; for (int i = 0; i < n; i++) { ans *= b[sa[i].length()]; ans += a[i]; ans %= mod; } System.out.println(ans); } }