結果

問題 No.222 引き算と足し算
ユーザー spaciaspacia
提出日時 2016-01-04 13:46:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 962 bytes
コンパイル時間 2,330 ms
コンパイル使用メモリ 78,640 KB
実行使用メモリ 37,364 KB
最終ジャッジ日時 2024-11-15 22:08:47
合計ジャッジ時間 5,175 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
37,272 KB
testcase_01 AC 56 ms
36,836 KB
testcase_02 AC 55 ms
37,212 KB
testcase_03 AC 56 ms
36,932 KB
testcase_04 AC 56 ms
37,288 KB
testcase_05 AC 56 ms
37,256 KB
testcase_06 AC 55 ms
37,364 KB
testcase_07 AC 55 ms
37,180 KB
testcase_08 AC 56 ms
36,704 KB
testcase_09 AC 56 ms
37,284 KB
testcase_10 AC 56 ms
37,248 KB
testcase_11 AC 58 ms
36,916 KB
testcase_12 AC 56 ms
37,144 KB
testcase_13 AC 58 ms
37,084 KB
testcase_14 AC 56 ms
37,160 KB
testcase_15 AC 55 ms
37,120 KB
testcase_16 AC 55 ms
36,836 KB
testcase_17 AC 55 ms
37,020 KB
testcase_18 AC 56 ms
37,040 KB
testcase_19 AC 58 ms
36,848 KB
testcase_20 AC 56 ms
37,152 KB
testcase_21 AC 56 ms
36,848 KB
testcase_22 AC 56 ms
36,704 KB
testcase_23 AC 56 ms
37,168 KB
testcase_24 AC 56 ms
36,968 KB
testcase_25 AC 55 ms
37,068 KB
testcase_26 AC 55 ms
37,116 KB
testcase_27 AC 56 ms
36,824 KB
testcase_28 AC 56 ms
37,248 KB
testcase_29 AC 55 ms
37,032 KB
testcase_30 AC 56 ms
36,708 KB
testcase_31 AC 56 ms
37,028 KB
testcase_32 AC 56 ms
37,152 KB
testcase_33 AC 57 ms
37,012 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