結果

問題 No.289 数字を全て足そう
ユーザー HaleakalaHaleakala
提出日時 2018-02-18 21:43:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 163 ms / 1,000 ms
コード長 407 bytes
コンパイル時間 4,148 ms
コンパイル使用メモリ 72,444 KB
実行使用メモリ 58,180 KB
最終ジャッジ日時 2023-09-17 21:35:38
合計ジャッジ時間 8,057 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,748 KB
testcase_01 AC 118 ms
56,116 KB
testcase_02 AC 119 ms
56,132 KB
testcase_03 AC 117 ms
55,856 KB
testcase_04 AC 119 ms
55,684 KB
testcase_05 AC 137 ms
58,180 KB
testcase_06 AC 129 ms
55,440 KB
testcase_07 AC 157 ms
55,896 KB
testcase_08 AC 156 ms
55,616 KB
testcase_09 AC 128 ms
55,908 KB
testcase_10 AC 131 ms
55,876 KB
testcase_11 AC 159 ms
55,744 KB
testcase_12 AC 162 ms
55,712 KB
testcase_13 AC 154 ms
55,784 KB
testcase_14 AC 159 ms
55,808 KB
testcase_15 AC 158 ms
55,692 KB
testcase_16 AC 153 ms
56,172 KB
testcase_17 AC 150 ms
55,836 KB
testcase_18 AC 159 ms
55,772 KB
testcase_19 AC 154 ms
56,124 KB
testcase_20 AC 161 ms
55,912 KB
testcase_21 AC 124 ms
55,688 KB
testcase_22 AC 161 ms
55,620 KB
testcase_23 AC 163 ms
56,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Answer {
	public static void main(String str[]) {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        int sum = 0;

        for(int i=0; i<s.length(); i++) {
        	char c = s.charAt(i);
        	if(Character.isDigit(c)) {
        		sum += Character.getNumericValue(c);
        	}
        }

        System.out.println(sum);
	}
}
0