結果

問題 No.222 引き算と足し算
ユーザー uafr_csuafr_cs
提出日時 2015-06-16 23:26:05
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 888 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 78,508 KB
実行使用メモリ 55,900 KB
最終ジャッジ日時 2024-04-27 17:42:02
合計ジャッジ時間 7,306 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
54,052 KB
testcase_01 AC 124 ms
54,088 KB
testcase_02 AC 123 ms
53,876 KB
testcase_03 AC 124 ms
54,328 KB
testcase_04 AC 129 ms
53,912 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 125 ms
54,020 KB
testcase_09 AC 109 ms
52,864 KB
testcase_10 AC 121 ms
53,908 KB
testcase_11 AC 122 ms
53,020 KB
testcase_12 AC 122 ms
53,760 KB
testcase_13 AC 109 ms
52,804 KB
testcase_14 AC 121 ms
53,980 KB
testcase_15 AC 123 ms
54,120 KB
testcase_16 AC 123 ms
53,860 KB
testcase_17 AC 125 ms
53,884 KB
testcase_18 AC 125 ms
54,008 KB
testcase_19 AC 125 ms
54,408 KB
testcase_20 AC 122 ms
54,092 KB
testcase_21 AC 128 ms
54,176 KB
testcase_22 AC 124 ms
53,888 KB
testcase_23 AC 122 ms
54,208 KB
testcase_24 AC 125 ms
54,036 KB
testcase_25 AC 123 ms
53,948 KB
testcase_26 AC 126 ms
54,024 KB
testcase_27 AC 124 ms
54,288 KB
testcase_28 AC 125 ms
54,068 KB
testcase_29 RE -
testcase_30 AC 123 ms
54,076 KB
testcase_31 AC 123 ms
54,116 KB
testcase_32 AC 125 ms
54,248 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String input = sc.next();
		
		boolean is_minus = false;
		if(input.startsWith("-")){
			input = input.substring(1);
			is_minus = true;
		}else if(input.startsWith("+")){
			input = input.substring(1);
		}
		
		if(input.indexOf("+") >= 0){
			final int fst = (is_minus ? -1 : 1) * Integer.parseInt(input.substring(0, input.indexOf("+")));
			final int snd = Integer.parseInt(input.substring(input.indexOf("+") + 1, input.length()));
			
			System.out.println(fst - snd);
		}else{
			final int fst = (is_minus ? -1 : 1) * Integer.parseInt(input.substring(0, input.indexOf("-")));
			final int snd = Integer.parseInt(input.substring(input.indexOf("-") + 1, input.length()));
			
			System.out.println(fst + snd);
		}
		
	}
	
}
0