結果

問題 No.289 数字を全て足そう
ユーザー kameyama_s
提出日時 2023-05-31 13:06:30
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 498 bytes
コンパイル時間 4,499 ms
コンパイル使用メモリ 83,680 KB
実行使用メモリ 42,920 KB
最終ジャッジ日時 2024-12-28 13:44:52
合計ジャッジ時間 7,889 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 RE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String intStr = s.replaceAll("[^0-9]","");
        Integer number = Integer.valueOf(intStr);
        System.out.println(sumDigits(number));
    }
    
    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }
}
0