結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
jp_ste
|
| 提出日時 | 2016-05-10 17:22:46 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 5,000 ms |
| コード長 | 851 bytes |
| コンパイル時間 | 4,141 ms |
| コンパイル使用メモリ | 75,128 KB |
| 実行使用メモリ | 41,512 KB |
| 最終ジャッジ日時 | 2024-12-23 01:51:39 |
| 合計ジャッジ時間 | 5,946 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
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]);
}
}
}
jp_ste