結果

問題 No.222 引き算と足し算
ユーザー nCk_cvnCk_cv
提出日時 2015-08-03 01:52:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 903 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 77,204 KB
実行使用メモリ 41,420 KB
最終ジャッジ日時 2024-04-27 17:46:10
合計ジャッジ時間 6,207 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
40,860 KB
testcase_01 AC 108 ms
41,296 KB
testcase_02 AC 104 ms
41,224 KB
testcase_03 AC 104 ms
40,828 KB
testcase_04 AC 105 ms
41,264 KB
testcase_05 AC 101 ms
40,932 KB
testcase_06 AC 111 ms
41,388 KB
testcase_07 AC 104 ms
40,860 KB
testcase_08 AC 91 ms
40,028 KB
testcase_09 AC 101 ms
41,236 KB
testcase_10 AC 116 ms
40,996 KB
testcase_11 AC 92 ms
39,968 KB
testcase_12 AC 92 ms
39,928 KB
testcase_13 AC 109 ms
41,104 KB
testcase_14 AC 99 ms
40,876 KB
testcase_15 AC 101 ms
40,780 KB
testcase_16 AC 91 ms
39,980 KB
testcase_17 AC 104 ms
41,268 KB
testcase_18 AC 100 ms
40,320 KB
testcase_19 AC 89 ms
39,652 KB
testcase_20 AC 112 ms
40,920 KB
testcase_21 AC 104 ms
40,868 KB
testcase_22 AC 100 ms
40,980 KB
testcase_23 AC 96 ms
41,016 KB
testcase_24 AC 102 ms
41,100 KB
testcase_25 AC 100 ms
41,400 KB
testcase_26 AC 102 ms
41,120 KB
testcase_27 AC 117 ms
41,420 KB
testcase_28 AC 90 ms
39,724 KB
testcase_29 AC 109 ms
41,248 KB
testcase_30 AC 115 ms
41,088 KB
testcase_31 AC 101 ms
40,956 KB
testcase_32 AC 92 ms
40,212 KB
testcase_33 AC 92 ms
40,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] in = sc.next().toCharArray();
		StringBuilder a = new StringBuilder();
		boolean startA = true;
		boolean startB = false;
		StringBuilder b = new StringBuilder();
		boolean opPlus = false;;
		for(int i = 0; i < in.length; i++) {
			if(i != 0 && !startB && (in[i] == '+' || in[i] == '-')) {
				if(in[i] == '+') {
					opPlus = true;
				}
				startB = true;
				continue;
			}
			if(!startB)
			a.append(in[i]);
			else {
				b.append(in[i]);
			}
		}
		
		
		
		int A = Integer.parseInt(a.toString());
		int B = Integer.parseInt(b.toString());
		
		
		System.out.println(opPlus?(A-B):(A+B));
		
		
		
		
	}
	
	static class Data {
		int[][] mapA;
		int[][] mapB;
		int count;
		
		Data(int[][] a, int [][] b , int count) {
			mapA = a;
			mapB = b;
			this.count = count;
		}
	}
}
0