結果

問題 No.222 引き算と足し算
ユーザー GrenacheGrenache
提出日時 2015-06-08 12:12:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 1,000 ms
コード長 790 bytes
コンパイル時間 3,274 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 54,424 KB
最終ジャッジ日時 2024-04-27 17:40:42
合計ジャッジ時間 8,489 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
54,092 KB
testcase_01 AC 123 ms
54,132 KB
testcase_02 AC 123 ms
53,868 KB
testcase_03 AC 122 ms
54,120 KB
testcase_04 AC 124 ms
54,136 KB
testcase_05 AC 124 ms
54,108 KB
testcase_06 AC 124 ms
54,280 KB
testcase_07 AC 122 ms
53,800 KB
testcase_08 AC 123 ms
53,820 KB
testcase_09 AC 111 ms
52,700 KB
testcase_10 AC 123 ms
53,860 KB
testcase_11 AC 127 ms
53,928 KB
testcase_12 AC 125 ms
54,424 KB
testcase_13 AC 125 ms
54,040 KB
testcase_14 AC 127 ms
54,044 KB
testcase_15 AC 121 ms
53,860 KB
testcase_16 AC 124 ms
54,140 KB
testcase_17 AC 127 ms
53,996 KB
testcase_18 AC 128 ms
53,956 KB
testcase_19 AC 124 ms
54,148 KB
testcase_20 AC 122 ms
54,060 KB
testcase_21 AC 124 ms
54,084 KB
testcase_22 AC 125 ms
54,124 KB
testcase_23 AC 124 ms
54,240 KB
testcase_24 AC 126 ms
54,004 KB
testcase_25 AC 124 ms
53,820 KB
testcase_26 AC 124 ms
54,044 KB
testcase_27 AC 111 ms
52,996 KB
testcase_28 AC 124 ms
54,328 KB
testcase_29 AC 111 ms
52,856 KB
testcase_30 AC 120 ms
53,988 KB
testcase_31 AC 127 ms
54,020 KB
testcase_32 AC 127 ms
53,928 KB
testcase_33 AC 125 ms
54,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main_yukicoder222 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String xopy = sc.next();

        String regex = "([+-]?\\d+)([+-])([+-]?\\d+)";
        Pattern p = Pattern.compile(regex);
        
        Matcher m = p.matcher(xopy);
        if (m.find()) {
        	int x = Integer.parseInt(m.group(1));
        	String op = m.group(2);
        	int y = Integer.parseInt(m.group(3));
        	
        	if (op.equals("+")) {
        		System.out.println(x - y);
        	} else {
        		System.out.println(x + y);
        	}
        } else {
        	System.out.println("NG");
        }
        
        sc.close();
    }
}
0