結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,060 KB
testcase_01 AC 128 ms
41,352 KB
testcase_02 AC 130 ms
41,276 KB
testcase_03 AC 115 ms
40,244 KB
testcase_04 AC 128 ms
40,796 KB
testcase_05 AC 155 ms
42,720 KB
testcase_06 AC 143 ms
42,056 KB
testcase_07 AC 170 ms
41,976 KB
testcase_08 AC 166 ms
42,916 KB
testcase_09 AC 152 ms
43,648 KB
testcase_10 AC 160 ms
42,696 KB
testcase_11 AC 165 ms
42,952 KB
testcase_12 AC 170 ms
42,364 KB
testcase_13 AC 166 ms
42,232 KB
testcase_14 AC 171 ms
42,140 KB
testcase_15 AC 166 ms
42,592 KB
testcase_16 AC 166 ms
42,816 KB
testcase_17 AC 164 ms
42,884 KB
testcase_18 AC 169 ms
41,888 KB
testcase_19 AC 169 ms
42,740 KB
testcase_20 AC 162 ms
42,128 KB
testcase_21 AC 131 ms
41,232 KB
testcase_22 AC 168 ms
41,784 KB
testcase_23 AC 153 ms
41,224 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 += s.charAt(i) - '0';
			}
			System.out.println(ans);
		}
	}
}
0