結果

問題 No.222 引き算と足し算
ユーザー kuramukuramu
提出日時 2016-02-11 09:37:05
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 900 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 75,536 KB
実行使用メモリ 52,632 KB
最終ジャッジ日時 2024-04-27 17:51:40
合計ジャッジ時間 4,318 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,524 KB
testcase_01 AC 52 ms
50,396 KB
testcase_02 AC 50 ms
50,124 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 49 ms
50,504 KB
testcase_09 AC 49 ms
50,336 KB
testcase_10 AC 52 ms
50,536 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 49 ms
50,124 KB
testcase_15 AC 49 ms
50,532 KB
testcase_16 AC 49 ms
50,364 KB
testcase_17 AC 51 ms
50,620 KB
testcase_18 RE -
testcase_19 AC 49 ms
50,476 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 51 ms
49,960 KB
testcase_31 RE -
testcase_32 AC 50 ms
50,240 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.*;
public class Main {

	 public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      try {
	    	  String line = stdReader.readLine();
	    	  if(line.charAt(0)=='+'){
	    		  line = line.substring(1,line.length());
	    	  }
	    	  Pattern pattern = Pattern.compile("\\+");
	    	  Matcher matcher = pattern.matcher(line);
	    	  if(matcher.find()){
	    		  String[] temps = line.split("\\+");
	    		  System.out.println(Integer.parseInt(temps[0])-Integer.parseInt(temps[1]));
	    	  }else{
	    		  String[] temps = line.split("\\-");
	    		  System.out.println(Integer.parseInt(temps[0])+Integer.parseInt(temps[1]));
	    	  }
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0