結果
問題 | No.49 算数の宿題 |
ユーザー | jp_ste |
提出日時 | 2016-05-10 17:22:46 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 133 ms / 5,000 ms |
コード長 | 851 bytes |
コンパイル時間 | 3,451 ms |
コンパイル使用メモリ | 73,288 KB |
実行使用メモリ | 55,912 KB |
最終ジャッジ日時 | 2023-08-24 17:32:20 |
合計ジャッジ時間 | 5,719 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
55,672 KB |
testcase_01 | AC | 126 ms
55,720 KB |
testcase_02 | AC | 127 ms
55,664 KB |
testcase_03 | AC | 133 ms
55,912 KB |
testcase_04 | AC | 127 ms
55,472 KB |
testcase_05 | AC | 128 ms
55,724 KB |
testcase_06 | AC | 125 ms
55,696 KB |
testcase_07 | AC | 131 ms
55,728 KB |
testcase_08 | AC | 129 ms
55,612 KB |
testcase_09 | AC | 130 ms
55,680 KB |
ソースコード
import java.util.Scanner; public class Main2 { public static void main(String[] args) { try (Scanner scan = new Scanner(System.in)) { String S = scan.next(); String strList[] = S.split("\\*|\\+"); int list[] = new int[strList.length]; for(int i=0; i<list.length; i++) { list[i] = Integer.parseInt(strList[i]); } int count = 1; for(int i=0; i<S.length(); i++) { char ch = S.charAt(i); if(ch == '*') { list[0] = list[0] + list[count]; count++; } else if(ch == '+') { list[0] = list[0] * list[count]; count++; } } System.out.println(list[0]); } } }