結果

問題 No.222 引き算と足し算
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-16 04:24:26
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 935 bytes
コンパイル時間 3,891 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 57,920 KB
最終ジャッジ日時 2023-08-17 07:18:36
合計ジャッジ時間 7,971 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,804 KB
testcase_01 AC 121 ms
55,576 KB
testcase_02 AC 119 ms
55,604 KB
testcase_03 AC 119 ms
55,596 KB
testcase_04 AC 119 ms
55,696 KB
testcase_05 RE -
testcase_06 AC 118 ms
55,584 KB
testcase_07 AC 119 ms
55,660 KB
testcase_08 AC 120 ms
55,688 KB
testcase_09 AC 118 ms
55,788 KB
testcase_10 AC 119 ms
55,688 KB
testcase_11 RE -
testcase_12 AC 120 ms
53,636 KB
testcase_13 AC 120 ms
55,600 KB
testcase_14 AC 117 ms
55,952 KB
testcase_15 AC 118 ms
55,848 KB
testcase_16 AC 119 ms
55,448 KB
testcase_17 WA -
testcase_18 AC 119 ms
55,916 KB
testcase_19 AC 120 ms
55,936 KB
testcase_20 AC 120 ms
55,988 KB
testcase_21 AC 119 ms
55,664 KB
testcase_22 AC 119 ms
55,844 KB
testcase_23 AC 117 ms
55,640 KB
testcase_24 AC 120 ms
55,680 KB
testcase_25 RE -
testcase_26 AC 120 ms
55,988 KB
testcase_27 AC 120 ms
55,600 KB
testcase_28 RE -
testcase_29 AC 122 ms
55,784 KB
testcase_30 AC 122 ms
55,960 KB
testcase_31 AC 119 ms
55,780 KB
testcase_32 AC 119 ms
55,572 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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){
            S=S.substring(1);
            n=S.indexOf("+")+1;
        }
        if(n<=0){
            n=Integer.MAX_VALUE;
        }
        int m = S.indexOf("-");
        if(m==0){
            S=S.substring(1);
            m=S.indexOf("-")+1;
        }
        if(m<=0){
            m=Integer.MAX_VALUE;
        }
        return Math.min(n,m);
    }
}

0