結果

問題 No.222 引き算と足し算
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-16 04:13:46
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 753 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 71,880 KB
実行使用メモリ 57,964 KB
最終ジャッジ日時 2023-08-17 07:18:14
合計ジャッジ時間 6,828 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
55,668 KB
testcase_01 AC 110 ms
53,592 KB
testcase_02 AC 106 ms
55,668 KB
testcase_03 AC 108 ms
55,964 KB
testcase_04 AC 110 ms
55,632 KB
testcase_05 AC 108 ms
55,948 KB
testcase_06 RE -
testcase_07 AC 110 ms
55,572 KB
testcase_08 RE -
testcase_09 AC 107 ms
55,808 KB
testcase_10 AC 110 ms
55,408 KB
testcase_11 AC 109 ms
56,072 KB
testcase_12 RE -
testcase_13 AC 110 ms
55,660 KB
testcase_14 RE -
testcase_15 AC 108 ms
55,660 KB
testcase_16 AC 109 ms
55,344 KB
testcase_17 AC 107 ms
55,464 KB
testcase_18 RE -
testcase_19 AC 109 ms
56,164 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 103 ms
55,964 KB
testcase_24 RE -
testcase_25 AC 112 ms
55,636 KB
testcase_26 AC 107 ms
55,640 KB
testcase_27 RE -
testcase_28 AC 109 ms
55,960 KB
testcase_29 AC 108 ms
55,916 KB
testcase_30 AC 105 ms
55,800 KB
testcase_31 AC 110 ms
55,960 KB
testcase_32 AC 105 ms
55,380 KB
testcase_33 AC 110 ms
55,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String xopy = sc.next();
        int z = ind(xopy);
        int x = Integer.parseInt( xopy.substring(0,z) );
        int y = Integer.parseInt( xopy.substring(z+1) );
        String op = xopy.substring(z,z+1);
        int r =0;
        if( op.equals("+") ){
            r = x-y;
        }else{
            r = x+y;
        }
        System.out.println(r);
    }
    static int ind(String S){
        int n = S.indexOf("+");
        if(n<=0){
            n=Integer.MAX_VALUE;
        }
        int m = S.indexOf("-");
        if(m<=0){
            m=Integer.MAX_VALUE;
        }
        return Math.min(n,m);
    }
}
0