結果

問題 No.289 数字を全て足そう
ユーザー SuunnSuunn
提出日時 2018-11-22 09:15:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 1,000 ms
コード長 346 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 72,300 KB
実行使用メモリ 56,692 KB
最終ジャッジ日時 2023-08-26 02:48:42
合計ジャッジ時間 5,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
55,776 KB
testcase_01 AC 109 ms
56,068 KB
testcase_02 AC 109 ms
55,616 KB
testcase_03 AC 110 ms
56,604 KB
testcase_04 AC 110 ms
56,072 KB
testcase_05 AC 113 ms
56,132 KB
testcase_06 AC 116 ms
56,692 KB
testcase_07 AC 122 ms
56,624 KB
testcase_08 AC 121 ms
55,820 KB
testcase_09 AC 110 ms
56,152 KB
testcase_10 AC 119 ms
55,952 KB
testcase_11 AC 121 ms
55,664 KB
testcase_12 AC 123 ms
56,344 KB
testcase_13 AC 118 ms
56,308 KB
testcase_14 AC 118 ms
56,244 KB
testcase_15 AC 117 ms
55,796 KB
testcase_16 AC 119 ms
56,180 KB
testcase_17 AC 128 ms
56,076 KB
testcase_18 AC 120 ms
55,844 KB
testcase_19 AC 120 ms
56,328 KB
testcase_20 AC 121 ms
56,452 KB
testcase_21 AC 108 ms
55,612 KB
testcase_22 AC 123 ms
56,080 KB
testcase_23 AC 122 ms
56,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
	

public class Main{
	
	
	public static void main(String args[])throws Exception{
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int L = S.length();
		int ans = 0;
		for(int i=0;i<L;i++){
			char c = S.charAt(i);
			if('1'<=c&&c<='9'){
				ans += c-'1'+1;
			}
		}
		System.out.println(ans);
	}
	

}
0