結果

問題 No.289 数字を全て足そう
ユーザー sasakkisasakki
提出日時 2016-03-28 12:28:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 166 ms / 1,000 ms
コード長 385 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 81,252 KB
実行使用メモリ 42,332 KB
最終ジャッジ日時 2024-04-16 21:04:29
合計ジャッジ時間 6,550 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,616 KB
testcase_01 AC 128 ms
41,564 KB
testcase_02 AC 128 ms
41,244 KB
testcase_03 AC 129 ms
41,168 KB
testcase_04 AC 131 ms
41,056 KB
testcase_05 AC 137 ms
41,376 KB
testcase_06 AC 132 ms
41,832 KB
testcase_07 AC 146 ms
41,840 KB
testcase_08 AC 151 ms
41,836 KB
testcase_09 AC 138 ms
41,552 KB
testcase_10 AC 145 ms
41,476 KB
testcase_11 AC 149 ms
41,472 KB
testcase_12 AC 150 ms
41,720 KB
testcase_13 AC 147 ms
41,352 KB
testcase_14 AC 150 ms
41,576 KB
testcase_15 AC 149 ms
41,404 KB
testcase_16 AC 149 ms
41,776 KB
testcase_17 AC 150 ms
41,668 KB
testcase_18 AC 148 ms
41,408 KB
testcase_19 AC 147 ms
41,216 KB
testcase_20 AC 158 ms
41,624 KB
testcase_21 AC 128 ms
41,372 KB
testcase_22 AC 150 ms
41,680 KB
testcase_23 AC 166 ms
42,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.lang.Character;

class main{
    public static void main(String args[]){
	Scanner scan = new Scanner(System.in);
	
	int ans = 0;

	String str = scan.next();

	for(int i = 0; i < str.length(); i++){
	    char ch = str.charAt(i);
	   
	    if( Character.isDigit(ch) ){
		ans += Integer.parseInt("" +ch);
	    }
	}

	System.out.println(ans);

    }
}
0