結果

問題 No.289 数字を全て足そう
ユーザー yuuki121yuuki121
提出日時 2021-01-02 23:36:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 496 bytes
コンパイル時間 1,940 ms
コンパイル使用メモリ 74,908 KB
実行使用メモリ 55,888 KB
最終ジャッジ日時 2024-04-20 18:22:27
合計ジャッジ時間 5,569 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
50,520 KB
testcase_01 AC 51 ms
50,492 KB
testcase_02 AC 54 ms
50,268 KB
testcase_03 AC 55 ms
50,268 KB
testcase_04 AC 54 ms
50,488 KB
testcase_05 AC 103 ms
54,744 KB
testcase_06 AC 98 ms
52,424 KB
testcase_07 AC 129 ms
55,792 KB
testcase_08 AC 131 ms
55,812 KB
testcase_09 AC 98 ms
54,480 KB
testcase_10 AC 100 ms
54,540 KB
testcase_11 AC 123 ms
55,716 KB
testcase_12 AC 135 ms
55,840 KB
testcase_13 AC 126 ms
55,380 KB
testcase_14 AC 138 ms
55,640 KB
testcase_15 AC 124 ms
55,236 KB
testcase_16 AC 116 ms
55,488 KB
testcase_17 AC 128 ms
55,864 KB
testcase_18 AC 132 ms
55,636 KB
testcase_19 AC 126 ms
55,636 KB
testcase_20 AC 128 ms
55,888 KB
testcase_21 AC 53 ms
50,512 KB
testcase_22 AC 129 ms
55,640 KB
testcase_23 AC 141 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		int sum = 0;

		for (int i = 0; i < str.length(); i++) {
			String target = String.valueOf(str.charAt(i));
			sum += target.matches("[0-9]") ? Integer.parseInt(target) : 0;
		}

		System.out.println(sum);

	}

}
0