結果
問題 |
No.289 数字を全て足そう
|
ユーザー |
|
提出日時 | 2021-01-02 23:36:37 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 151 ms / 1,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 2,227 ms |
コンパイル使用メモリ | 73,448 KB |
実行使用メモリ | 44,476 KB |
最終ジャッジ日時 | 2024-10-12 14:20:51 |
合計ジャッジ時間 | 5,950 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int sum = 0; for (int i = 0; i < str.length(); i++) { String target = String.valueOf(str.charAt(i)); sum += target.matches("[0-9]") ? Integer.parseInt(target) : 0; } System.out.println(sum); } }