結果
問題 | No.2086 A+B問題 |
ユーザー | 👑 kakel-san |
提出日時 | 2022-09-30 21:35:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,162 bytes |
コンパイル時間 | 1,514 ms |
コンパイル使用メモリ | 68,236 KB |
実行使用メモリ | 23,564 KB |
最終ジャッジ日時 | 2023-08-24 14:56:07 |
合計ジャッジ時間 | 3,423 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
21,484 KB |
testcase_01 | AC | 52 ms
23,404 KB |
testcase_02 | AC | 53 ms
23,484 KB |
testcase_03 | AC | 53 ms
21,264 KB |
testcase_04 | AC | 52 ms
21,356 KB |
testcase_05 | AC | 52 ms
23,416 KB |
testcase_06 | AC | 53 ms
21,292 KB |
testcase_07 | AC | 52 ms
23,388 KB |
testcase_08 | AC | 53 ms
23,344 KB |
testcase_09 | WA | - |
testcase_10 | AC | 57 ms
21,584 KB |
testcase_11 | AC | 55 ms
21,508 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 57 ms
23,564 KB |
testcase_16 | AC | 57 ms
23,488 KB |
testcase_17 | AC | 56 ms
23,552 KB |
testcase_18 | AC | 53 ms
23,296 KB |
testcase_19 | WA | - |
testcase_20 | AC | 53 ms
21,316 KB |
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] LList(int n) => Enumerable.Repeat(0, n).Select(_ => int.Parse(ReadLine())).ToArray(); static void Main() { Solve(); } static void Solve() { var a = ReadLine().ToList(); var b = ReadLine().ToList(); if (a.Count > b.Count) b = Enumerable.Repeat('0', a.Count - b.Count).Concat(b).ToList(); if (a.Count < b.Count) a = Enumerable.Repeat('0', b.Count - a.Count).Concat(a).ToList(); var res = new List<char>(); var up = 0; for (var i = a.Count - 1; i >= 0; --i) { var sum = (a[i] - '0') + (b[i] - '0') + up; if (sum >= 10) { sum -=10; up = 1; } res.Add((char)(sum + '0')); } if (up > 0) res.Add((char)(up + '0')); res.Reverse(); WriteLine(string.Concat(res)); } }