結果

問題 No.289 数字を全て足そう
ユーザー springspring
提出日時 2019-06-12 14:15:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 180 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 75,536 KB
実行使用メモリ 43,652 KB
最終ジャッジ日時 2024-04-18 13:48:06
合計ジャッジ時間 6,847 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,264 KB
testcase_01 AC 117 ms
41,100 KB
testcase_02 AC 128 ms
41,420 KB
testcase_03 AC 128 ms
41,184 KB
testcase_04 AC 127 ms
41,312 KB
testcase_05 AC 163 ms
42,584 KB
testcase_06 AC 141 ms
41,960 KB
testcase_07 AC 165 ms
42,272 KB
testcase_08 AC 176 ms
42,832 KB
testcase_09 AC 169 ms
41,836 KB
testcase_10 AC 168 ms
42,944 KB
testcase_11 AC 172 ms
42,132 KB
testcase_12 AC 171 ms
42,500 KB
testcase_13 AC 163 ms
42,224 KB
testcase_14 AC 159 ms
42,472 KB
testcase_15 AC 170 ms
42,260 KB
testcase_16 AC 167 ms
42,740 KB
testcase_17 AC 174 ms
42,040 KB
testcase_18 AC 180 ms
42,596 KB
testcase_19 AC 161 ms
42,208 KB
testcase_20 AC 170 ms
43,652 KB
testcase_21 AC 124 ms
40,172 KB
testcase_22 AC 168 ms
41,960 KB
testcase_23 AC 136 ms
41,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		String regex = "[^0-9]";
		Pattern p = Pattern.compile(regex);

		Matcher m = p.matcher(input);
		String inputA = m.replaceAll("");
		char[] charStr = inputA.toCharArray();
		int result = 0;
		for(char charNum : charStr){
			result += Character.getNumericValue(charNum);
		}
		System.out.println(result);

	}// mainmethod

} // class
0