結果
| 問題 | 
                            No.49 算数の宿題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2014-11-19 18:29:29 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 508 bytes | 
| コンパイル時間 | 4,056 ms | 
| コンパイル使用メモリ | 75,412 KB | 
| 実行使用メモリ | 54,360 KB | 
| 最終ジャッジ日時 | 2024-12-23 01:42:54 | 
| 合計ジャッジ時間 | 5,539 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 8 WA * 2 | 
ソースコード
import java.util.Scanner;
public class Yukicoder49 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] a = s.split("[*+]");
		String sign = s.replaceAll("[1-9]", "");
		int res;
		res = Integer.parseInt(a[0]);
		for (int i = 1; i < a.length; i++) {
			if (sign.charAt(i - 1) == '*') res += Integer.parseInt(a[i]);
			else if (sign.charAt(i - 1) == '+') res *= Integer.parseInt(a[i]);
		}
		System.out.println(res);
	}
}