結果

問題 No.289 数字を全て足そう
ユーザー MatumoMatumo
提出日時 2018-07-13 03:14:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 188 ms / 1,000 ms
コード長 360 bytes
コンパイル時間 2,632 ms
コンパイル使用メモリ 75,312 KB
実行使用メモリ 42,280 KB
最終ジャッジ日時 2024-04-15 11:09:27
合計ジャッジ時間 7,704 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
41,084 KB
testcase_01 AC 152 ms
41,660 KB
testcase_02 AC 151 ms
41,696 KB
testcase_03 AC 148 ms
41,440 KB
testcase_04 AC 145 ms
41,476 KB
testcase_05 AC 157 ms
41,204 KB
testcase_06 AC 155 ms
41,628 KB
testcase_07 AC 175 ms
41,676 KB
testcase_08 AC 173 ms
41,736 KB
testcase_09 AC 158 ms
41,728 KB
testcase_10 AC 171 ms
41,716 KB
testcase_11 AC 172 ms
41,588 KB
testcase_12 AC 170 ms
41,964 KB
testcase_13 AC 169 ms
41,620 KB
testcase_14 AC 177 ms
42,280 KB
testcase_15 AC 173 ms
41,608 KB
testcase_16 AC 175 ms
41,540 KB
testcase_17 AC 164 ms
41,376 KB
testcase_18 AC 181 ms
41,808 KB
testcase_19 AC 176 ms
41,984 KB
testcase_20 AC 179 ms
41,636 KB
testcase_21 AC 160 ms
42,060 KB
testcase_22 AC 177 ms
41,940 KB
testcase_23 AC 188 ms
41,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String s = sc.next();
		int ans = 0;

		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(Character.isDigit(c)) ans += Integer.parseInt(Character.toString(c));
		}
		
		System.out.println(ans);
    }
}
0