結果
問題 |
No.289 数字を全て足そう
|
ユーザー |
![]() |
提出日時 | 2017-10-02 21:16:34 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 171 ms / 1,000 ms |
コード長 | 490 bytes |
コンパイル時間 | 2,001 ms |
コンパイル使用メモリ | 75,204 KB |
実行使用メモリ | 42,684 KB |
最終ジャッジ日時 | 2024-11-15 22:41:59 |
合計ジャッジ時間 | 6,436 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import java.util.LinkedList; import java.util.Scanner; public class Main{ private static Scanner sc=new Scanner(System.in); public static void main(String args[])throws Exception{ String s=sc.nextLine(); int sum=0; s=s.replaceAll("[^0-9]",""); LinkedList<Integer>queue=new LinkedList<Integer>(); for(char element:s.toCharArray()){ queue.offer(Character.getNumericValue(element)); }while(queue.isEmpty()==false){ sum+=queue.removeFirst(); }System.out.println(sum); } }