結果

問題 No.222 引き算と足し算
コンテスト
ユーザー ルッツファン
提出日時 2015-11-28 04:26:22
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 1,497 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,549 ms
コンパイル使用メモリ 84,996 KB
実行使用メモリ 43,892 KB
最終ジャッジ日時 2026-09-23 17:30:18
合計ジャッジ時間 5,957 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 4 RE * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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("\\+");
			if(rew.length == 2){
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				
				System.out.println(a-b);
				return;
			}
			if(tes.indexOf("\\-") == 1){
				
				rew = tes.split("\\-");
				
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				
				System.out.println(a+b);
				return;
				
			}else if(tes.indexOf("\\-") == 3){
				rew = tes.split("\\-");
				
				int a = Integer.parseInt(rew[0]);
				int b = Integer.parseInt(rew[1]);
				
				a = -1*a;
				b = -1*b;
				
				System.out.println(a+b);
				return;
			}else if(tes.indexOf("\\-") == 1 && tes.substring(0, 0).equals("\\-") ){
				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