結果

問題 No.222 引き算と足し算
ユーザー ぴろずぴろず
提出日時 2015-06-05 22:32:28
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 668 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 71,616 KB
実行使用メモリ 56,048 KB
最終ジャッジ日時 2023-08-09 23:04:11
合計ジャッジ時間 7,587 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,340 KB
testcase_01 AC 120 ms
55,392 KB
testcase_02 AC 120 ms
55,828 KB
testcase_03 AC 118 ms
55,944 KB
testcase_04 AC 122 ms
55,644 KB
testcase_05 AC 120 ms
55,768 KB
testcase_06 AC 120 ms
55,900 KB
testcase_07 AC 121 ms
53,804 KB
testcase_08 AC 121 ms
55,720 KB
testcase_09 AC 121 ms
56,048 KB
testcase_10 AC 122 ms
55,672 KB
testcase_11 AC 119 ms
55,752 KB
testcase_12 AC 121 ms
55,552 KB
testcase_13 AC 124 ms
55,720 KB
testcase_14 AC 120 ms
55,584 KB
testcase_15 AC 121 ms
55,608 KB
testcase_16 AC 121 ms
55,500 KB
testcase_17 AC 120 ms
55,532 KB
testcase_18 AC 121 ms
55,748 KB
testcase_19 AC 122 ms
55,680 KB
testcase_20 AC 121 ms
55,660 KB
testcase_21 AC 120 ms
55,564 KB
testcase_22 AC 130 ms
55,484 KB
testcase_23 AC 121 ms
55,716 KB
testcase_24 AC 120 ms
55,488 KB
testcase_25 AC 120 ms
55,640 KB
testcase_26 AC 120 ms
55,528 KB
testcase_27 AC 120 ms
55,648 KB
testcase_28 AC 121 ms
55,548 KB
testcase_29 AC 122 ms
55,288 KB
testcase_30 AC 120 ms
55,596 KB
testcase_31 AC 119 ms
55,548 KB
testcase_32 AC 121 ms
55,856 KB
testcase_33 AC 123 ms
55,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no222;

import java.util.Scanner;

public class Main {

	static char[] s;
	static int ind = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		s = sc.next().toCharArray();
		int a = number();
		char op = s[ind++];
		int b = number();
		if (op == '+') {
			System.out.println(a-b);
		}else{
			System.out.println(a+b);
		}
	}

	public static int number() {
		boolean negative = false;
		if (s[ind] == '+') {
			ind++;
		}else if(s[ind] == '-') {
			ind++;
			negative = true;
		}
		int n = 0;
		while(ind < s.length && Character.isDigit(s[ind])) {
			n = n * 10 + s[ind] - '0';
			ind++;
		}
		return negative ? -n : n;
	}

}
0