結果

問題 No.289 数字を全て足そう
ユーザー dazydazy
提出日時 2016-09-02 01:53:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 621 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 74,616 KB
実行使用メモリ 56,428 KB
最終ジャッジ日時 2024-04-27 14:41:24
合計ジャッジ時間 6,102 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
53,740 KB
testcase_01 AC 116 ms
54,168 KB
testcase_02 AC 116 ms
53,872 KB
testcase_03 AC 105 ms
52,584 KB
testcase_04 AC 114 ms
53,884 KB
testcase_05 AC 141 ms
53,904 KB
testcase_06 AC 138 ms
53,952 KB
testcase_07 AC 152 ms
56,340 KB
testcase_08 AC 155 ms
56,016 KB
testcase_09 AC 127 ms
54,168 KB
testcase_10 AC 134 ms
54,200 KB
testcase_11 AC 149 ms
56,084 KB
testcase_12 AC 154 ms
56,428 KB
testcase_13 AC 152 ms
56,076 KB
testcase_14 AC 145 ms
56,108 KB
testcase_15 AC 147 ms
55,976 KB
testcase_16 AC 145 ms
53,736 KB
testcase_17 AC 157 ms
56,084 KB
testcase_18 AC 160 ms
56,292 KB
testcase_19 AC 150 ms
55,872 KB
testcase_20 AC 151 ms
55,876 KB
testcase_21 AC 121 ms
54,116 KB
testcase_22 AC 155 ms
56,296 KB
testcase_23 AC 154 ms
56,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Yukicoder {
    static public void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        if (S.isEmpty() || S.length() > 10000) System.exit(1);

        Pattern p = Pattern.compile("\\d");
        String tmp;
        int sum = 0;
        for (int i = 0; i < S.length(); i++) {
            tmp = S.substring(i, i+1);
            Matcher m = p.matcher(tmp);
            if (m.find()) sum += Integer.parseInt(tmp);
        }
        System.out.println(sum);
    }
}
0