結果

問題 No.708 (+ー)の式
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-14 03:13:19
言語 Kuin
(KuinC++ v.2021.9.17)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 145,748 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 16:08:33
合計ジャッジ時間 2,527 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var ans: int :: 0
	var s: []char :: cui@input()
	var n: int :: ^s
	var st: int :: 0
	var minus: bool :: false
	var nest: bool :: false
	for i(0, ^s - 1)
		switch(s[i])
		case '('
			do nest :: true
		case ')'
			do nest :: false
			if(minus)
				do ans :- st
			else
				do ans :+ st
			end if
			do st :: 0
			do minus :: false
		case '+'
		case '-'
			if(!nest)
				do minus :: true
			end if
		default
			if(!nest)
				if(i = 0 | s[i - 1] <> '-')
					do ans :+ s[i] $ int - '0' $ int
				else
					do ans :- s[i] $ int - '0' $ int
				end if
			else
				if(i = 0 | s[i - 1] <> '-')
					do st :+ s[i] $ int - '0' $ int
				else
					do st :- s[i] $ int - '0' $ int
				end if
			end if
		end switch
	end for
	do cui@print("\{ans}\n")
end func
0