結果

問題 No.289 数字を全て足そう
ユーザー oldlevinoldlevin
提出日時 2020-02-21 07:09:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 69 ms / 1,000 ms
コード長 573 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 110,944 KB
実行使用メモリ 25,344 KB
最終ジャッジ日時 2024-04-17 06:42:57
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
23,424 KB
testcase_01 AC 62 ms
22,912 KB
testcase_02 AC 64 ms
23,552 KB
testcase_03 AC 62 ms
23,168 KB
testcase_04 AC 59 ms
23,296 KB
testcase_05 AC 66 ms
23,552 KB
testcase_06 AC 66 ms
23,680 KB
testcase_07 AC 68 ms
25,088 KB
testcase_08 AC 67 ms
24,576 KB
testcase_09 AC 65 ms
23,552 KB
testcase_10 AC 65 ms
23,936 KB
testcase_11 AC 67 ms
24,448 KB
testcase_12 AC 67 ms
25,088 KB
testcase_13 AC 64 ms
24,320 KB
testcase_14 AC 68 ms
25,344 KB
testcase_15 AC 69 ms
24,576 KB
testcase_16 AC 66 ms
24,320 KB
testcase_17 AC 68 ms
24,448 KB
testcase_18 AC 68 ms
25,088 KB
testcase_19 AC 66 ms
24,576 KB
testcase_20 AC 66 ms
24,704 KB
testcase_21 AC 60 ms
23,296 KB
testcase_22 AC 66 ms
24,832 KB
testcase_23 AC 63 ms
23,296 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 System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Console;

public class hello{
    public static void Main(){   //yukikoder No.289 数字を全て足そう
                                           
        string str = ReadLine().Trim() ;
        str = Regex.Replace(str,"[^0-9]","");//文字配列(数字のみを抽出)
        var n = str.Select(x => Convert.ToInt32(x.ToString()));//char -> string -> int   
        
        //配列要素の総和
        WriteLine(n.Sum());
    }
}


0