結果

問題 No.222 引き算と足し算
ユーザー sue_charosue_charo
提出日時 2017-04-27 17:18:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 698 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 71,820 KB
実行使用メモリ 57,708 KB
最終ジャッジ日時 2023-10-11 16:06:56
合計ジャッジ時間 7,563 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,584 KB
testcase_01 AC 119 ms
55,792 KB
testcase_02 AC 120 ms
55,636 KB
testcase_03 AC 120 ms
55,668 KB
testcase_04 AC 120 ms
55,688 KB
testcase_05 AC 119 ms
55,736 KB
testcase_06 AC 119 ms
57,708 KB
testcase_07 AC 121 ms
55,928 KB
testcase_08 AC 119 ms
55,680 KB
testcase_09 AC 118 ms
55,416 KB
testcase_10 AC 121 ms
56,048 KB
testcase_11 AC 120 ms
55,632 KB
testcase_12 AC 120 ms
53,876 KB
testcase_13 AC 121 ms
55,860 KB
testcase_14 AC 122 ms
55,684 KB
testcase_15 AC 121 ms
53,300 KB
testcase_16 AC 121 ms
55,784 KB
testcase_17 AC 121 ms
55,328 KB
testcase_18 AC 119 ms
55,976 KB
testcase_19 AC 120 ms
55,740 KB
testcase_20 AC 123 ms
55,524 KB
testcase_21 AC 119 ms
55,648 KB
testcase_22 AC 121 ms
55,616 KB
testcase_23 AC 120 ms
55,652 KB
testcase_24 AC 121 ms
55,612 KB
testcase_25 AC 121 ms
55,916 KB
testcase_26 AC 119 ms
55,844 KB
testcase_27 AC 119 ms
55,628 KB
testcase_28 AC 121 ms
55,572 KB
testcase_29 AC 119 ms
55,660 KB
testcase_30 AC 121 ms
55,640 KB
testcase_31 AC 119 ms
55,364 KB
testcase_32 AC 119 ms
55,812 KB
testcase_33 AC 120 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String get = sc.next();
        int count = 0;

        for (int i = 1; i < get.length(); i++) {
            if (! Character.isDigit(get.charAt(i))) {
                count = i;
                break;
            }
        }

        int a = Integer.parseInt(get.substring(0, count));
        int b = Integer.parseInt(get.substring(count + 1, get.length()));
        char op = get.charAt(count);

        int ans;

        if (op == '+') {
            ans = a - b;
        } else {
            ans = a + b;
        }

        System.out.println(ans);
    }
}
0