結果
問題 | No.2086 A+B問題 |
ユーザー |
|
提出日時 | 2022-09-30 21:37:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,188 bytes |
コンパイル時間 | 908 ms |
コンパイル使用メモリ | 111,652 KB |
実行使用メモリ | 26,720 KB |
最終ジャッジ日時 | 2024-12-22 22:41:40 |
合計ジャッジ時間 | 2,229 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}}