結果

問題 No.289 数字を全て足そう
ユーザー yamax3232yamax3232
提出日時 2017-02-10 17:47:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 1,000 ms
コード長 544 bytes
コンパイル時間 3,537 ms
コンパイル使用メモリ 74,020 KB
実行使用メモリ 56,204 KB
最終ジャッジ日時 2023-08-27 06:55:21
合計ジャッジ時間 7,654 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,616 KB
testcase_01 AC 118 ms
55,876 KB
testcase_02 AC 119 ms
55,640 KB
testcase_03 AC 117 ms
55,592 KB
testcase_04 AC 119 ms
55,668 KB
testcase_05 AC 128 ms
55,816 KB
testcase_06 AC 123 ms
55,728 KB
testcase_07 AC 136 ms
55,788 KB
testcase_08 AC 136 ms
55,712 KB
testcase_09 AC 123 ms
55,652 KB
testcase_10 AC 133 ms
55,884 KB
testcase_11 AC 135 ms
55,728 KB
testcase_12 AC 141 ms
55,988 KB
testcase_13 AC 134 ms
53,864 KB
testcase_14 AC 136 ms
55,864 KB
testcase_15 AC 135 ms
55,692 KB
testcase_16 AC 135 ms
55,448 KB
testcase_17 AC 133 ms
55,696 KB
testcase_18 AC 137 ms
56,028 KB
testcase_19 AC 130 ms
55,924 KB
testcase_20 AC 134 ms
56,204 KB
testcase_21 AC 116 ms
55,912 KB
testcase_22 AC 137 ms
55,616 KB
testcase_23 AC 144 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class PlusAll {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner kb=new Scanner(System.in);
String a=kb.next();
int sum=0;
int n;
for(int i=0;i<a.length();i++){
	if(a.charAt(i)=='1'||
			a.charAt(i)=='2'||
			a.charAt(i)=='3'||
			a.charAt(i)=='4'||
			a.charAt(i)=='5'||
			a.charAt(i)=='6'||
			a.charAt(i)=='7'||
			a.charAt(i)=='8'||
			a.charAt(i)=='9'){
		n=Integer.parseInt(""+a.charAt(i));
		sum+=n;
	}
}
System.out.printf("%d\n", sum);
	}

}
0