結果

問題 No.289 数字を全て足そう
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-20 12:05:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 182 ms / 1,000 ms
コード長 416 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 57,208 KB
最終ジャッジ日時 2024-04-10 02:28:15
合計ジャッジ時間 6,443 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
52,712 KB
testcase_01 AC 119 ms
54,132 KB
testcase_02 AC 111 ms
52,708 KB
testcase_03 AC 119 ms
54,288 KB
testcase_04 AC 107 ms
52,996 KB
testcase_05 AC 129 ms
55,416 KB
testcase_06 AC 133 ms
54,096 KB
testcase_07 AC 164 ms
56,936 KB
testcase_08 AC 165 ms
56,968 KB
testcase_09 AC 140 ms
56,328 KB
testcase_10 AC 155 ms
56,404 KB
testcase_11 AC 168 ms
56,888 KB
testcase_12 AC 179 ms
56,948 KB
testcase_13 AC 163 ms
57,152 KB
testcase_14 AC 182 ms
57,036 KB
testcase_15 AC 169 ms
57,208 KB
testcase_16 AC 163 ms
56,876 KB
testcase_17 AC 161 ms
57,048 KB
testcase_18 AC 182 ms
57,000 KB
testcase_19 AC 167 ms
56,876 KB
testcase_20 AC 163 ms
56,720 KB
testcase_21 AC 106 ms
52,848 KB
testcase_22 AC 181 ms
57,032 KB
testcase_23 AC 145 ms
53,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for(int i = 0; i < s.length(); i++) {
      String d = String.valueOf(s.charAt(i));
      try {
        int num = Integer.parseInt(d);
        ans += num;
      } catch(NumberFormatException e) {
      }
    }
    System.out.println(ans);
  }
}
0