結果

問題 No.49 算数の宿題
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-29 19:44:24
言語 Java19
(openjdk 21)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 488 bytes
コンパイル時間 2,407 ms
コンパイル使用メモリ 72,784 KB
実行使用メモリ 56,336 KB
最終ジャッジ日時 2023-08-24 17:40:30
合計ジャッジ時間 4,348 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,544 KB
testcase_01 AC 115 ms
53,860 KB
testcase_02 AC 116 ms
55,320 KB
testcase_03 AC 118 ms
55,744 KB
testcase_04 AC 118 ms
55,868 KB
testcase_05 AC 117 ms
56,040 KB
testcase_06 AC 117 ms
56,084 KB
testcase_07 AC 117 ms
56,336 KB
testcase_08 AC 117 ms
55,416 KB
testcase_09 AC 118 ms
55,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		String x[]=s.split("[\\+\\*]");
		int tmp=Integer.parseInt(x[0]);
		int j=1;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='+') {
				tmp*=Integer.parseInt(x[j]);
				j++;
			}else if(s.charAt(i)=='*') {
				tmp+=Integer.parseInt(x[j]);
				j++;
			}
		}
		System.out.println(tmp);
	}
}
0