結果

問題 No.289 数字を全て足そう
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-01-01 14:52:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 186 ms / 1,000 ms
コード長 545 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 74,644 KB
実行使用メモリ 57,308 KB
最終ジャッジ日時 2024-04-16 20:59:52
合計ジャッジ時間 6,486 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
54,052 KB
testcase_01 AC 118 ms
54,192 KB
testcase_02 AC 115 ms
54,036 KB
testcase_03 AC 121 ms
54,404 KB
testcase_04 AC 123 ms
54,112 KB
testcase_05 AC 150 ms
56,364 KB
testcase_06 AC 128 ms
52,932 KB
testcase_07 AC 158 ms
57,012 KB
testcase_08 AC 173 ms
56,960 KB
testcase_09 AC 133 ms
55,660 KB
testcase_10 AC 140 ms
55,792 KB
testcase_11 AC 167 ms
56,952 KB
testcase_12 AC 181 ms
57,164 KB
testcase_13 AC 169 ms
57,088 KB
testcase_14 AC 184 ms
57,308 KB
testcase_15 AC 162 ms
57,040 KB
testcase_16 AC 161 ms
57,272 KB
testcase_17 AC 160 ms
56,892 KB
testcase_18 AC 186 ms
57,260 KB
testcase_19 AC 162 ms
56,972 KB
testcase_20 AC 160 ms
57,184 KB
testcase_21 AC 123 ms
53,876 KB
testcase_22 AC 186 ms
56,788 KB
testcase_23 AC 139 ms
54,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class NumAdd {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int c, ans;
        ans = 0;
        for(int i = 0; i < str.length(); i++) {
            try {
                char x = str.charAt(i);
                String y = Character.toString(x);
                c = Integer.parseInt(y);
            } catch(Exception e) {
                continue;
            }
            ans += c;
        }
        System.out.println(ans);
    }
}
0