結果
問題 | No.2086 A+B問題 |
ユーザー |
![]() |
提出日時 | 2022-09-30 21:29:00 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 2,409 ms |
コンパイル使用メモリ | 213,812 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 16:19:02 |
合計ジャッジ時間 | 2,681 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
import std;void main() {string A, B;readf("%s\n%s\n", A, B);auto x = A.length, y = B.length;long mn = min(x, y), mx = max(x, y);int num;int[] res;foreach (i; 0 .. mn) {int u = A[x-i-1] - '0', v = B[y-i-1] - '0';int S = u + v + num;res ~= S % 10;num = S / 10;}string C = (x >= y ? A : B);foreach (i; mn .. mx) {int S = C[mx-i-1] - '0' + num;res ~= S % 10;num = S / 10;}if (num > 0) res ~= num;res.reverse;writefln("%(%s%)", res);}