結果

問題 No.289 数字を全て足そう
ユーザー n_gojon_gojo
提出日時 2020-04-09 18:43:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 1,000 ms
コード長 506 bytes
コンパイル時間 3,383 ms
コンパイル使用メモリ 71,884 KB
実行使用メモリ 57,776 KB
最終ジャッジ日時 2023-10-11 21:22:44
合計ジャッジ時間 7,981 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,588 KB
testcase_01 AC 118 ms
55,824 KB
testcase_02 AC 120 ms
55,744 KB
testcase_03 AC 120 ms
57,776 KB
testcase_04 AC 117 ms
55,492 KB
testcase_05 AC 128 ms
56,020 KB
testcase_06 AC 126 ms
55,908 KB
testcase_07 AC 140 ms
56,060 KB
testcase_08 AC 136 ms
56,048 KB
testcase_09 AC 127 ms
55,628 KB
testcase_10 AC 134 ms
55,720 KB
testcase_11 AC 136 ms
55,840 KB
testcase_12 AC 139 ms
54,012 KB
testcase_13 AC 135 ms
55,688 KB
testcase_14 AC 139 ms
55,388 KB
testcase_15 AC 135 ms
55,680 KB
testcase_16 AC 132 ms
56,044 KB
testcase_17 AC 137 ms
55,588 KB
testcase_18 AC 139 ms
55,928 KB
testcase_19 AC 138 ms
55,704 KB
testcase_20 AC 138 ms
55,588 KB
testcase_21 AC 119 ms
55,308 KB
testcase_22 AC 139 ms
55,860 KB
testcase_23 AC 142 ms
56,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No289 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);

        String str = sc.next();
        int ans = 0;

        for (int i = 0; i < str.length(); i++) {
            if (Character.isDigit(str.charAt(i))) {
                ans += Character.digit(str.charAt(i), 10);
            }
        }
        System.out.println(ans);
    }
}
0