結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
mosmos_21
|
| 提出日時 | 2017-06-18 21:19:58 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 546 bytes |
| コンパイル時間 | 2,618 ms |
| コンパイル使用メモリ | 74,908 KB |
| 実行使用メモリ | 41,372 KB |
| 最終ジャッジ日時 | 2024-12-23 01:57:37 |
| 合計ジャッジ時間 | 4,382 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 9 |
ソースコード
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);
}
}
mosmos_21