結果

問題 No.289 数字を全て足そう
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-12 20:09:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 211 ms / 1,000 ms
コード長 557 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 72,128 KB
実行使用メモリ 59,168 KB
最終ジャッジ日時 2023-08-17 03:54:59
合計ジャッジ時間 7,293 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,644 KB
testcase_01 AC 122 ms
55,816 KB
testcase_02 AC 118 ms
55,284 KB
testcase_03 AC 117 ms
55,452 KB
testcase_04 AC 116 ms
55,536 KB
testcase_05 AC 166 ms
58,136 KB
testcase_06 AC 150 ms
56,504 KB
testcase_07 AC 194 ms
58,668 KB
testcase_08 AC 192 ms
58,824 KB
testcase_09 AC 163 ms
58,400 KB
testcase_10 AC 171 ms
58,844 KB
testcase_11 AC 188 ms
58,908 KB
testcase_12 AC 208 ms
59,168 KB
testcase_13 AC 188 ms
58,600 KB
testcase_14 AC 198 ms
58,780 KB
testcase_15 AC 188 ms
58,944 KB
testcase_16 AC 179 ms
58,404 KB
testcase_17 AC 195 ms
58,324 KB
testcase_18 AC 211 ms
58,704 KB
testcase_19 AC 191 ms
58,820 KB
testcase_20 AC 191 ms
58,944 KB
testcase_21 AC 118 ms
55,888 KB
testcase_22 AC 205 ms
59,088 KB
testcase_23 AC 182 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String [] arr = S.split("");
        int sum = 0;
        for(int i=0; i<arr.length; i++){
            int temp = parseint(arr[i],0);
            sum += temp;
        }
        System.out.println(sum);
    }
    static int parseint(String a, int b){
        try{
            return Integer.parseInt(a);
        } catch ( NumberFormatException e ) {
            return b;
        }
    }
}
0