結果

問題 No.289 数字を全て足そう
ユーザー Ryota EnokidoRyota Enokido
提出日時 2018-12-12 10:22:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 176 ms / 1,000 ms
コード長 502 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 73,984 KB
実行使用メモリ 57,876 KB
最終ジャッジ日時 2023-10-25 08:21:50
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,544 KB
testcase_01 AC 134 ms
57,572 KB
testcase_02 AC 131 ms
57,580 KB
testcase_03 AC 134 ms
57,536 KB
testcase_04 AC 134 ms
57,604 KB
testcase_05 AC 143 ms
57,652 KB
testcase_06 AC 143 ms
57,576 KB
testcase_07 AC 162 ms
57,580 KB
testcase_08 AC 162 ms
57,680 KB
testcase_09 AC 142 ms
57,580 KB
testcase_10 AC 151 ms
57,576 KB
testcase_11 AC 159 ms
57,552 KB
testcase_12 AC 175 ms
57,624 KB
testcase_13 AC 160 ms
57,556 KB
testcase_14 AC 174 ms
57,584 KB
testcase_15 AC 159 ms
57,588 KB
testcase_16 AC 173 ms
57,876 KB
testcase_17 AC 174 ms
57,820 KB
testcase_18 AC 175 ms
57,544 KB
testcase_19 AC 158 ms
57,756 KB
testcase_20 AC 159 ms
55,540 KB
testcase_21 AC 132 ms
57,548 KB
testcase_22 AC 172 ms
57,592 KB
testcase_23 AC 176 ms
57,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
  
  public class Main {
      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          
          int sum = 0;
          String s = sc.nextLine();
     
          for(int i=0; i<s.length(); i++){
              if(Character.isDigit(s.charAt(i))){
                  sum += Character.getNumericValue(s.charAt(i));
              }else{
                  continue;
              }
          }
          System.out.println(sum);
      }
  }
0