結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
50,268 KB
testcase_01 AC 47 ms
49,700 KB
testcase_02 AC 46 ms
49,664 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 48 ms
49,900 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 46 ms
50,032 KB
testcase_10 AC 46 ms
49,796 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 47 ms
49,708 KB
testcase_16 AC 45 ms
49,964 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 47 ms
49,652 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 46 ms
50,144 KB
testcase_31 RE -
testcase_32 AC 47 ms
49,864 KB
testcase_33 AC 48 ms
50,152 KB
権限があれば一括ダウンロードができます

ソースコード

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;
			}
			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