結果

問題 No.289 数字を全て足そう
ユーザー S1hoS1ho
提出日時 2017-02-19 14:33:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 522 bytes
コンパイル時間 3,555 ms
コンパイル使用メモリ 71,828 KB
実行使用メモリ 57,744 KB
最終ジャッジ日時 2023-08-28 19:13:05
合計ジャッジ時間 7,880 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
57,744 KB
testcase_01 AC 111 ms
56,252 KB
testcase_02 AC 110 ms
55,704 KB
testcase_03 AC 110 ms
55,556 KB
testcase_04 AC 110 ms
55,840 KB
testcase_05 AC 118 ms
56,068 KB
testcase_06 AC 116 ms
56,008 KB
testcase_07 AC 130 ms
55,904 KB
testcase_08 AC 128 ms
55,568 KB
testcase_09 AC 117 ms
56,124 KB
testcase_10 AC 124 ms
55,964 KB
testcase_11 AC 127 ms
56,056 KB
testcase_12 AC 129 ms
55,412 KB
testcase_13 AC 128 ms
56,088 KB
testcase_14 AC 130 ms
55,864 KB
testcase_15 AC 127 ms
55,800 KB
testcase_16 AC 126 ms
56,388 KB
testcase_17 AC 126 ms
55,840 KB
testcase_18 AC 129 ms
55,676 KB
testcase_19 AC 127 ms
55,928 KB
testcase_20 AC 127 ms
55,868 KB
testcase_21 AC 110 ms
55,712 KB
testcase_22 AC 131 ms
55,964 KB
testcase_23 AC 133 ms
55,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class AddAllNum {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        String s = scanner.next();
        
        int sum = 0;
        
        char c;
        
        for(int i=0;i<s.length();i++){
            
            c = s.charAt(i);
            
            if(Character.isDigit(c)){
                sum += Character.digit(c,10);
            } 
        }
        
        System.out.println(sum);
    }
    
}
0