結果

問題 No.289 数字を全て足そう
ユーザー howakurohowakuro
提出日時 2015-11-06 07:38:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 1,000 ms
コード長 407 bytes
コンパイル時間 3,311 ms
コンパイル使用メモリ 74,528 KB
実行使用メモリ 47,288 KB
最終ジャッジ日時 2024-04-16 19:21:15
合計ジャッジ時間 8,112 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,168 KB
testcase_01 AC 124 ms
41,204 KB
testcase_02 AC 131 ms
41,148 KB
testcase_03 AC 124 ms
41,700 KB
testcase_04 AC 126 ms
41,312 KB
testcase_05 AC 161 ms
43,532 KB
testcase_06 AC 145 ms
42,784 KB
testcase_07 AC 187 ms
45,436 KB
testcase_08 AC 189 ms
45,936 KB
testcase_09 AC 148 ms
42,832 KB
testcase_10 AC 166 ms
44,032 KB
testcase_11 AC 185 ms
45,252 KB
testcase_12 AC 201 ms
47,288 KB
testcase_13 AC 164 ms
45,548 KB
testcase_14 AC 193 ms
46,388 KB
testcase_15 AC 168 ms
45,508 KB
testcase_16 AC 176 ms
45,196 KB
testcase_17 AC 175 ms
45,760 KB
testcase_18 AC 197 ms
47,076 KB
testcase_19 AC 181 ms
45,964 KB
testcase_20 AC 168 ms
46,104 KB
testcase_21 AC 128 ms
41,440 KB
testcase_22 AC 197 ms
46,548 KB
testcase_23 AC 157 ms
41,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class NumberAdd {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S =  scan.next();
		int c = 0;
		int f;
		for(int i=0;i<S.length();i++){
			try{
				char x = S.charAt(i);
				String y = Character.toString(x);
				f = Integer.parseInt(y);
			}catch(Exception e){
			 continue;
			}
			c += f;
		}
		System.out.println(c);
	}

}
0