結果

問題 No.289 数字を全て足そう
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-14 09:50:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 1,000 ms
コード長 397 bytes
コンパイル時間 2,411 ms
コンパイル使用メモリ 76,048 KB
実行使用メモリ 43,660 KB
最終ジャッジ日時 2024-04-28 19:01:43
合計ジャッジ時間 7,287 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,560 KB
testcase_01 AC 133 ms
41,500 KB
testcase_02 AC 138 ms
41,444 KB
testcase_03 AC 133 ms
41,388 KB
testcase_04 AC 135 ms
40,964 KB
testcase_05 AC 176 ms
41,996 KB
testcase_06 AC 157 ms
41,580 KB
testcase_07 AC 182 ms
42,088 KB
testcase_08 AC 175 ms
42,232 KB
testcase_09 AC 158 ms
43,120 KB
testcase_10 AC 154 ms
43,152 KB
testcase_11 AC 168 ms
41,716 KB
testcase_12 AC 175 ms
41,892 KB
testcase_13 AC 167 ms
42,188 KB
testcase_14 AC 177 ms
42,316 KB
testcase_15 AC 169 ms
42,156 KB
testcase_16 AC 166 ms
42,796 KB
testcase_17 AC 172 ms
42,332 KB
testcase_18 AC 179 ms
42,284 KB
testcase_19 AC 180 ms
42,184 KB
testcase_20 AC 173 ms
43,660 KB
testcase_21 AC 131 ms
41,232 KB
testcase_22 AC 190 ms
41,880 KB
testcase_23 AC 155 ms
40,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		s = s.replaceAll("[A-Za-z]", "");
		if(s.length() == 0) {
			System.out.println(0);
		} else {
			int ans = 0;
			for(int i = 0 ; i < s.length() ; i++) {
				ans += Integer.valueOf("" + s.charAt(i));
			}
			System.out.println(ans);
		}
	}
}
0