結果

問題 No.49 算数の宿題
ユーザー mosmos_21mosmos_21
提出日時 2017-06-18 21:19:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 72,152 KB
実行使用メモリ 56,384 KB
最終ジャッジ日時 2023-08-24 17:37:36
合計ジャッジ時間 3,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        String[] s = in.nextLine().replaceAll("(\\+|\\*)", "_$1_").split("_");
        int sum = Integer.parseInt(s[0]);
        for(int i = 1; i < s.length; i += 2){
            if(s[i].equals("+")){
                sum += Integer.parseInt(s[i + 1]);
            }else if(s[i].equals("*")){
                sum += Integer.parseInt(s[i + 1]);
            }
        }
        System.out.println(sum);
    }
}
0