結果

問題 No.289 数字を全て足そう
ユーザー chiyodachiyoda
提出日時 2016-06-23 18:15:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 380 bytes
コンパイル時間 2,418 ms
コンパイル使用メモリ 75,308 KB
実行使用メモリ 57,896 KB
最終ジャッジ日時 2024-04-19 23:50:39
合計ジャッジ時間 5,952 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
53,520 KB
testcase_01 AC 111 ms
53,960 KB
testcase_02 AC 100 ms
52,784 KB
testcase_03 AC 108 ms
54,080 KB
testcase_04 AC 114 ms
54,060 KB
testcase_05 AC 132 ms
56,460 KB
testcase_06 AC 116 ms
52,708 KB
testcase_07 AC 154 ms
57,308 KB
testcase_08 AC 153 ms
57,148 KB
testcase_09 AC 125 ms
55,884 KB
testcase_10 AC 128 ms
55,540 KB
testcase_11 AC 158 ms
57,108 KB
testcase_12 AC 173 ms
57,896 KB
testcase_13 AC 152 ms
56,872 KB
testcase_14 AC 171 ms
56,740 KB
testcase_15 AC 155 ms
57,008 KB
testcase_16 AC 122 ms
55,960 KB
testcase_17 AC 160 ms
56,820 KB
testcase_18 AC 175 ms
57,044 KB
testcase_19 AC 167 ms
56,860 KB
testcase_20 AC 161 ms
56,652 KB
testcase_21 AC 112 ms
54,104 KB
testcase_22 AC 174 ms
56,944 KB
testcase_23 AC 141 ms
53,364 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();
    int res = 0;
    for  (int i = 0; i  < s.length(); i++) {
      try {
          res += Integer.valueOf(s.substring(i, i+1));
      } catch (NumberFormatException e) {    
      }
    }
    System.out.println(res);
  }
}
0