結果

問題 No.289 数字を全て足そう
ユーザー hikari2004hikari2004
提出日時 2016-04-20 11:33:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 1,000 ms
コード長 365 bytes
コンパイル時間 3,636 ms
コンパイル使用メモリ 74,612 KB
実行使用メモリ 41,976 KB
最終ジャッジ日時 2024-04-16 21:05:22
合計ジャッジ時間 8,008 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,372 KB
testcase_01 AC 129 ms
41,536 KB
testcase_02 AC 130 ms
41,240 KB
testcase_03 AC 130 ms
41,164 KB
testcase_04 AC 134 ms
41,456 KB
testcase_05 AC 144 ms
41,132 KB
testcase_06 AC 137 ms
41,136 KB
testcase_07 AC 150 ms
41,400 KB
testcase_08 AC 150 ms
41,412 KB
testcase_09 AC 137 ms
41,464 KB
testcase_10 AC 148 ms
41,436 KB
testcase_11 AC 151 ms
41,484 KB
testcase_12 AC 156 ms
41,400 KB
testcase_13 AC 149 ms
41,620 KB
testcase_14 AC 152 ms
41,924 KB
testcase_15 AC 149 ms
41,320 KB
testcase_16 AC 147 ms
41,540 KB
testcase_17 AC 151 ms
41,252 KB
testcase_18 AC 153 ms
41,976 KB
testcase_19 AC 150 ms
41,412 KB
testcase_20 AC 151 ms
41,552 KB
testcase_21 AC 129 ms
41,136 KB
testcase_22 AC 151 ms
41,468 KB
testcase_23 AC 159 ms
41,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No289 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.next();

		int ans = 0;

		for(int i = 0; i < line.length(); i++){
			char ch = line.charAt(i);
			if(Character.isDigit(ch)){
				ans += Integer.parseInt(String.valueOf(ch));
			}
		}
		System.out.println(ans);
	}

}
0