結果

問題 No.2086 A+B問題
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-30 21:35:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 3,272 ms
コンパイル使用メモリ 113,532 KB
実行使用メモリ 26,852 KB
最終ジャッジ日時 2024-06-02 05:06:02
合計ジャッジ時間 4,472 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,440 KB
testcase_01 AC 25 ms
26,236 KB
testcase_02 AC 25 ms
26,104 KB
testcase_03 AC 24 ms
24,500 KB
testcase_04 AC 24 ms
24,056 KB
testcase_05 AC 25 ms
26,540 KB
testcase_06 AC 23 ms
22,072 KB
testcase_07 AC 24 ms
24,500 KB
testcase_08 AC 24 ms
18,304 KB
testcase_09 WA -
testcase_10 AC 25 ms
18,688 KB
testcase_11 AC 25 ms
18,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 26 ms
18,944 KB
testcase_16 AC 24 ms
18,560 KB
testcase_17 AC 24 ms
18,688 KB
testcase_18 AC 21 ms
18,688 KB
testcase_19 WA -
testcase_20 AC 22 ms
18,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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