結果

問題 No.289 数字を全て足そう
ユーザー l1267976l1267976
提出日時 2017-03-07 22:21:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 448 bytes
コンパイル時間 3,261 ms
コンパイル使用メモリ 72,520 KB
実行使用メモリ 56,496 KB
最終ジャッジ日時 2023-09-05 22:36:27
合計ジャッジ時間 7,675 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,884 KB
testcase_01 AC 113 ms
55,716 KB
testcase_02 AC 116 ms
55,644 KB
testcase_03 AC 116 ms
56,064 KB
testcase_04 AC 114 ms
55,752 KB
testcase_05 AC 122 ms
56,008 KB
testcase_06 AC 121 ms
55,728 KB
testcase_07 AC 134 ms
56,092 KB
testcase_08 AC 132 ms
55,752 KB
testcase_09 AC 118 ms
56,056 KB
testcase_10 AC 127 ms
56,144 KB
testcase_11 AC 133 ms
55,964 KB
testcase_12 AC 130 ms
55,544 KB
testcase_13 AC 128 ms
56,496 KB
testcase_14 AC 129 ms
56,088 KB
testcase_15 AC 129 ms
55,824 KB
testcase_16 AC 130 ms
56,168 KB
testcase_17 AC 132 ms
55,844 KB
testcase_18 AC 132 ms
56,220 KB
testcase_19 AC 130 ms
55,824 KB
testcase_20 AC 132 ms
54,116 KB
testcase_21 AC 118 ms
55,480 KB
testcase_22 AC 135 ms
55,996 KB
testcase_23 AC 134 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No289 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            if (Character.isDigit(c)) {
                sum += Character.digit(c, 10);
            }
        }

        System.out.println(sum);

        sc.close();
    }

}
0