結果

問題 No.289 数字を全て足そう
ユーザー r.suzukir.suzuki
提出日時 2015-12-08 17:01:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 171 ms / 1,000 ms
コード長 607 bytes
コンパイル時間 3,690 ms
コンパイル使用メモリ 74,636 KB
実行使用メモリ 41,812 KB
最終ジャッジ日時 2024-04-16 20:58:04
合計ジャッジ時間 8,258 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
40,840 KB
testcase_01 AC 134 ms
41,172 KB
testcase_02 AC 128 ms
41,128 KB
testcase_03 AC 127 ms
41,052 KB
testcase_04 AC 127 ms
41,108 KB
testcase_05 AC 147 ms
41,384 KB
testcase_06 AC 140 ms
41,248 KB
testcase_07 AC 171 ms
41,664 KB
testcase_08 AC 154 ms
41,752 KB
testcase_09 AC 141 ms
41,356 KB
testcase_10 AC 159 ms
41,272 KB
testcase_11 AC 151 ms
41,556 KB
testcase_12 AC 169 ms
41,656 KB
testcase_13 AC 164 ms
41,068 KB
testcase_14 AC 158 ms
41,812 KB
testcase_15 AC 154 ms
41,648 KB
testcase_16 AC 159 ms
41,512 KB
testcase_17 AC 159 ms
41,200 KB
testcase_18 AC 169 ms
41,636 KB
testcase_19 AC 164 ms
41,768 KB
testcase_20 AC 149 ms
40,772 KB
testcase_21 AC 126 ms
41,348 KB
testcase_22 AC 156 ms
41,748 KB
testcase_23 AC 169 ms
41,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No_289 {
	static String[] numbers = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

	static boolean checkOfWord(String c) {
		for (String n : numbers) {
			if (c.equals(n)) {
				return true;
			}
		}
		return false;
	}

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

		for (int i = 0; i < s.length(); i++) {
			String check = s.substring(i, i + 1);
			if (checkOfWord(check)) {
				int j = Integer.parseInt(check);
				sum += j;
			}
		}
		System.out.println(sum);
		sc.close();

	}

}
0