結果

問題 No.222 引き算と足し算
ユーザー ルッツファンルッツファン
提出日時 2015-11-28 05:01:00
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,774 bytes
コンパイル時間 2,703 ms
コンパイル使用メモリ 77,260 KB
実行使用メモリ 52,120 KB
最終ジャッジ日時 2024-04-27 17:50:20
合計ジャッジ時間 5,121 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
49,840 KB
testcase_01 AC 46 ms
49,844 KB
testcase_02 AC 46 ms
49,876 KB
testcase_03 AC 51 ms
50,076 KB
testcase_04 AC 48 ms
49,976 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 45 ms
49,812 KB
testcase_10 AC 45 ms
50,060 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 46 ms
49,860 KB
testcase_16 AC 47 ms
50,132 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 46 ms
49,932 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 45 ms
50,160 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 46 ms
50,184 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 45 ms
50,284 KB
testcase_31 AC 46 ms
50,032 KB
testcase_32 AC 45 ms
50,016 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class yukicoder011 {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;

			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			
			String[] rew = tes.split("\\+");
			
			//System.out.println(tes.indexOf("\\-"));
			
			char[] er = tes.toCharArray();
			int tmpp = 0;
			for(int i=0;i<tes.length();i++){
				if(er[i] == '-'){
					tmpp++;
				}
			}
			
			if(rew.length == 2){
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				
				System.out.println(a-b);
				return;
			}else if(rew.length == 3){
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[2]);
				
				System.out.println(a-b);
				return;
			}
			if(tmpp == 1){
				
				rew = tes.split("\\-");
				
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				System.out.println(a+b);
				return;
				
			}else if(tmpp == 3){
				rew = tes.split("\\-");
				
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[2]);
				
				a = -1*a;
				b = -1*b;
				
				System.out.println(a+b);
				return;
			}else if(tmpp == 1 && er[0] == '-'){
				rew = tes.split("\\-");
				
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				
				a = -1*a;
				
				System.out.println(a+b);
				return;
			}else{
				rew = tes.split("\\-");
				
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				
				b = -1*b;
				
				System.out.println(a+b);
				return;
			}
			
			
			
	}

}
0