結果

問題 No.2086 A+B問題
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-30 21:37:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,188 bytes
コンパイル時間 1,065 ms
コンパイル使用メモリ 62,056 KB
実行使用メモリ 23,548 KB
最終ジャッジ日時 2023-08-24 14:59:42
合計ジャッジ時間 3,688 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
23,308 KB
testcase_01 AC 52 ms
21,300 KB
testcase_02 AC 56 ms
21,396 KB
testcase_03 AC 53 ms
23,356 KB
testcase_04 AC 52 ms
23,204 KB
testcase_05 AC 51 ms
21,308 KB
testcase_06 AC 53 ms
23,300 KB
testcase_07 AC 52 ms
23,316 KB
testcase_08 AC 52 ms
21,304 KB
testcase_09 AC 55 ms
21,552 KB
testcase_10 AC 55 ms
19,444 KB
testcase_11 AC 55 ms
21,412 KB
testcase_12 AC 53 ms
21,188 KB
testcase_13 AC 53 ms
21,388 KB
testcase_14 AC 53 ms
21,340 KB
testcase_15 AC 56 ms
21,436 KB
testcase_16 AC 56 ms
23,548 KB
testcase_17 AC 56 ms
21,588 KB
testcase_18 AC 53 ms
21,356 KB
testcase_19 AC 54 ms
21,308 KB
testcase_20 AC 53 ms
21,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
            }
            else up = 0;
            res.Add((char)(sum + '0'));
        }
        if (up > 0) res.Add((char)(up + '0'));
        res.Reverse();
        WriteLine(string.Concat(res));
    }
}
0