結果

問題 No.222 引き算と足し算
ユーザー spaciaspacia
提出日時 2016-01-04 13:46:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 55 ms / 1,000 ms
コード長 962 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 77,716 KB
実行使用メモリ 50,624 KB
最終ジャッジ日時 2024-04-27 17:50:49
合計ジャッジ時間 4,442 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
50,244 KB
testcase_01 AC 49 ms
49,956 KB
testcase_02 AC 49 ms
50,316 KB
testcase_03 AC 49 ms
49,968 KB
testcase_04 AC 52 ms
50,164 KB
testcase_05 AC 51 ms
50,300 KB
testcase_06 AC 50 ms
50,356 KB
testcase_07 AC 49 ms
50,484 KB
testcase_08 AC 50 ms
50,456 KB
testcase_09 AC 50 ms
50,420 KB
testcase_10 AC 50 ms
50,468 KB
testcase_11 AC 50 ms
50,072 KB
testcase_12 AC 51 ms
50,436 KB
testcase_13 AC 51 ms
50,064 KB
testcase_14 AC 53 ms
50,200 KB
testcase_15 AC 55 ms
50,220 KB
testcase_16 AC 53 ms
50,068 KB
testcase_17 AC 53 ms
50,192 KB
testcase_18 AC 51 ms
50,236 KB
testcase_19 AC 51 ms
50,436 KB
testcase_20 AC 51 ms
50,444 KB
testcase_21 AC 48 ms
50,540 KB
testcase_22 AC 49 ms
50,316 KB
testcase_23 AC 50 ms
50,108 KB
testcase_24 AC 52 ms
50,132 KB
testcase_25 AC 50 ms
50,408 KB
testcase_26 AC 53 ms
50,100 KB
testcase_27 AC 51 ms
50,240 KB
testcase_28 AC 54 ms
50,036 KB
testcase_29 AC 54 ms
49,952 KB
testcase_30 AC 52 ms
50,404 KB
testcase_31 AC 50 ms
50,176 KB
testcase_32 AC 51 ms
50,624 KB
testcase_33 AC 48 ms
50,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		char[] c = br.readLine().toCharArray();
		int i = 0;
		
		boolean isNegative1 = false;
		if (c[i] == '+' || c[i] == '-') {
			isNegative1 = c[i++] == '-';
		}
		
		int num1 = 0;
		while ((c[i] + "").matches("[0-9]")) {
			num1 = num1 * 10 + (c[i++] - '0');
		}
		num1 = isNegative1 ? -num1 : num1;
		
		//out(num1);
		
		boolean isAdd = c[i++] == '-';
		
		//out(isAdd);
		
		boolean isNegative2 = false;
		if (c[i] == '+' || c[i] == '-') {
			isNegative2 = c[i++] == '-';
		}
		
		int num2 = 0;
		while (i < c.length) {
			num2 = num2 * 10 + (c[i++] - '0');
		}
		num2 = isNegative2 ? -num2 : num2;
		
		//out(num2);
		
		out(isAdd ? (num1 + num2) : (num1 - num2));
		
	}
}
0