結果
問題 | No.289 数字を全て足そう |
ユーザー |
|
提出日時 | 2016-09-02 01:53:43 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 174 ms / 1,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 3,427 ms |
コンパイル使用メモリ | 74,712 KB |
実行使用メモリ | 43,996 KB |
最終ジャッジ日時 | 2024-11-15 17:27:41 |
合計ジャッジ時間 | 7,876 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; class Yukicoder { static public void main(String[] args) { Scanner scanner = new Scanner(System.in); String S = scanner.next(); if (S.isEmpty() || S.length() > 10000) System.exit(1); Pattern p = Pattern.compile("\\d"); String tmp; int sum = 0; for (int i = 0; i < S.length(); i++) { tmp = S.substring(i, i+1); Matcher m = p.matcher(tmp); if (m.find()) sum += Integer.parseInt(tmp); } System.out.println(sum); } }