結果

問題 No.708 (+ー)の式
ユーザー simamumusimamumu
提出日時 2018-06-29 22:56:29
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-09-13 15:31:52
合計ジャッジ時間 1,075 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,912 KB
testcase_01 AC 14 ms
7,804 KB
testcase_02 AC 15 ms
7,800 KB
testcase_03 AC 14 ms
7,808 KB
testcase_04 AC 15 ms
7,968 KB
testcase_05 AC 15 ms
7,772 KB
testcase_06 AC 15 ms
7,804 KB
testcase_07 AC 15 ms
7,836 KB
testcase_08 AC 15 ms
7,720 KB
testcase_09 AC 15 ms
7,792 KB
testcase_10 AC 15 ms
7,772 KB
testcase_11 AC 14 ms
7,888 KB
testcase_12 AC 15 ms
7,720 KB
testcase_13 AC 15 ms
7,784 KB
testcase_14 AC 15 ms
7,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s_0 = list(input())

def calc(s):
	N = len(s)
	ans = int(s[0])
	num = False
	plus = True
	for i in range(1,N):
		if num:
			if plus:
				ans += int(s[i])
			else:
				ans -= int(s[i])
			num = False
		else:
			if s[i] == '+':
				plus = True
			else:
				plus = False
			num = True
	return ans
			
while '(' in s_0:
	left = s_0.index('(')
	right = s_0.index(')')
	s_dush = s_0[left+1:right]
	ans = calc(s_dush)
	s_0 = s_0[:left] + [str(ans)] + s_0[right+1:]
	
print(calc(s_0))
0