結果

問題 No.289 数字を全て足そう
ユーザー YamaKasaYamaKasa
提出日時 2018-04-19 16:00:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 227 ms / 1,000 ms
コード長 432 bytes
コンパイル時間 1,992 ms
コンパイル使用メモリ 72,148 KB
実行使用メモリ 60,216 KB
最終ジャッジ日時 2023-09-09 11:42:54
合計ジャッジ時間 7,718 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,704 KB
testcase_01 AC 121 ms
55,504 KB
testcase_02 AC 120 ms
55,584 KB
testcase_03 AC 120 ms
55,448 KB
testcase_04 AC 123 ms
55,432 KB
testcase_05 AC 177 ms
57,816 KB
testcase_06 AC 172 ms
58,192 KB
testcase_07 AC 217 ms
59,372 KB
testcase_08 AC 214 ms
60,216 KB
testcase_09 AC 176 ms
57,956 KB
testcase_10 AC 187 ms
58,144 KB
testcase_11 AC 215 ms
59,464 KB
testcase_12 AC 223 ms
58,560 KB
testcase_13 AC 211 ms
59,100 KB
testcase_14 AC 216 ms
59,048 KB
testcase_15 AC 216 ms
58,760 KB
testcase_16 AC 204 ms
58,628 KB
testcase_17 AC 219 ms
58,936 KB
testcase_18 AC 221 ms
59,192 KB
testcase_19 AC 209 ms
59,088 KB
testcase_20 AC 210 ms
58,872 KB
testcase_21 AC 126 ms
55,180 KB
testcase_22 AC 224 ms
59,560 KB
testcase_23 AC 227 ms
59,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		//System.out.println("半角英数字の文字列");
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		scanner.close();
		int sum = 0;
		for(int i = 0; i < str.length(); i++) {
			String s = str.substring(i,i+1);
			if(s.matches("[0-9]{1}")) {
				sum += Integer.parseInt(s);
			}
		}
		System.out.println(sum);
	}
}
0