結果

問題 No.289 数字を全て足そう
ユーザー h_tyokinuhatah_tyokinuhata
提出日時 2016-01-19 23:01:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 157 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 74,920 KB
実行使用メモリ 41,796 KB
最終ジャッジ日時 2024-04-16 21:01:14
合計ジャッジ時間 6,385 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
40,304 KB
testcase_01 AC 114 ms
40,236 KB
testcase_02 AC 125 ms
41,032 KB
testcase_03 AC 128 ms
41,136 KB
testcase_04 AC 129 ms
41,556 KB
testcase_05 AC 136 ms
41,228 KB
testcase_06 AC 133 ms
41,516 KB
testcase_07 AC 145 ms
41,124 KB
testcase_08 AC 140 ms
41,576 KB
testcase_09 AC 134 ms
41,320 KB
testcase_10 AC 143 ms
41,372 KB
testcase_11 AC 142 ms
41,540 KB
testcase_12 AC 146 ms
41,700 KB
testcase_13 AC 131 ms
40,348 KB
testcase_14 AC 133 ms
40,616 KB
testcase_15 AC 145 ms
41,652 KB
testcase_16 AC 131 ms
40,412 KB
testcase_17 AC 144 ms
41,296 KB
testcase_18 AC 148 ms
41,788 KB
testcase_19 AC 144 ms
41,656 KB
testcase_20 AC 148 ms
41,308 KB
testcase_21 AC 126 ms
41,444 KB
testcase_22 AC 129 ms
41,604 KB
testcase_23 AC 157 ms
41,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

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

		char charS[] = S.toCharArray();
		int cnt = 0;
		
		for(int i = 0;i < charS.length; i++) {
			if(charS[i] == '1' ||
			   charS[i] == '2' ||
		       charS[i] == '3' ||
			   charS[i] == '4' ||
			   charS[i] == '5' ||
			   charS[i] == '6' ||
			   charS[i] == '7' ||
			   charS[i] == '8' ||
			   charS[i] == '9') {
				cnt+=Integer.parseInt(String.valueOf(charS[i]));
			}
		}
		
		System.out.println(cnt);
	}
}
0