結果

問題 No.222 引き算と足し算
ユーザー 37zigen37zigen
提出日時 2020-02-19 11:22:37
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 74,112 KB
実行使用メモリ 58,288 KB
最終ジャッジ日時 2023-07-29 14:26:34
合計ジャッジ時間 7,437 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,980 KB
testcase_01 AC 113 ms
55,804 KB
testcase_02 AC 111 ms
55,536 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 112 ms
55,584 KB
testcase_10 AC 113 ms
55,408 KB
testcase_11 WA -
testcase_12 AC 113 ms
55,820 KB
testcase_13 AC 116 ms
56,216 KB
testcase_14 WA -
testcase_15 AC 113 ms
55,836 KB
testcase_16 AC 116 ms
55,980 KB
testcase_17 WA -
testcase_18 AC 110 ms
55,528 KB
testcase_19 AC 113 ms
54,368 KB
testcase_20 WA -
testcase_21 AC 112 ms
56,052 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 113 ms
55,792 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 113 ms
56,004 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 110 ms
55,692 KB
testcase_31 WA -
testcase_32 AC 112 ms
53,996 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		char[] cs=sc.next().toCharArray();
		int u=0,v=0;
		int su=1,sv=1;
		int p=0;
		if(cs[p]=='-') {
			++p;
			su*=-1;
		}
		while(cs[p]-'0'>=0&&9>=cs[p]-'0') {
			u=10*u+(int)(cs[p]-'0');
			++p;
		}
		if(cs[p]=='+')sv*=-1;
		++p;
		if(cs[p]=='-') {
			++p;
			sv*=-1;
		}
		while(p<cs.length&&cs[p]-'0'>=0&&9>=cs[p]-'0') {
			v=10*v+(int)(cs[p]-'0');
			++p;
		}
		System.out.println(su*u+sv*v);
		
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0