結果

問題 No.222 引き算と足し算
ユーザー rf141rf141
提出日時 2015-06-28 17:51:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 3,335 ms
コンパイル使用メモリ 75,640 KB
実行使用メモリ 54,388 KB
最終ジャッジ日時 2024-04-27 17:43:56
合計ジャッジ時間 8,507 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
54,332 KB
testcase_01 AC 122 ms
54,020 KB
testcase_02 AC 124 ms
53,952 KB
testcase_03 AC 123 ms
54,272 KB
testcase_04 AC 122 ms
54,388 KB
testcase_05 AC 122 ms
54,180 KB
testcase_06 AC 124 ms
54,352 KB
testcase_07 AC 121 ms
54,024 KB
testcase_08 AC 127 ms
54,072 KB
testcase_09 AC 122 ms
54,048 KB
testcase_10 AC 109 ms
52,748 KB
testcase_11 AC 125 ms
53,972 KB
testcase_12 AC 123 ms
54,048 KB
testcase_13 AC 126 ms
54,124 KB
testcase_14 AC 130 ms
54,072 KB
testcase_15 AC 123 ms
54,128 KB
testcase_16 AC 110 ms
53,040 KB
testcase_17 AC 126 ms
54,272 KB
testcase_18 AC 125 ms
53,960 KB
testcase_19 AC 124 ms
53,916 KB
testcase_20 AC 122 ms
54,048 KB
testcase_21 AC 124 ms
54,140 KB
testcase_22 AC 121 ms
54,128 KB
testcase_23 AC 119 ms
54,080 KB
testcase_24 AC 109 ms
54,260 KB
testcase_25 AC 122 ms
54,004 KB
testcase_26 AC 122 ms
53,948 KB
testcase_27 AC 122 ms
54,024 KB
testcase_28 AC 122 ms
53,952 KB
testcase_29 AC 122 ms
53,864 KB
testcase_30 AC 123 ms
54,120 KB
testcase_31 AC 110 ms
52,896 KB
testcase_32 AC 122 ms
54,268 KB
testcase_33 AC 123 ms
54,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class CalcPlusMinus {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String get = scan.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()));
	    
		System.out.println((get.charAt(count)=='+')?(a-b):(a+b));
	}
}
0