結果

問題 No.193 筒の数式
ユーザー ktshunktshun
提出日時 2015-06-04 20:02:06
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 591 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 6,744 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2023-09-20 19:10:11
合計ジャッジ時間 1,159 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,032 KB
testcase_01 AC 12 ms
5,940 KB
testcase_02 AC 12 ms
5,944 KB
testcase_03 AC 12 ms
6,044 KB
testcase_04 AC 12 ms
6,032 KB
testcase_05 AC 11 ms
5,888 KB
testcase_06 AC 11 ms
5,944 KB
testcase_07 AC 11 ms
5,940 KB
testcase_08 AC 11 ms
6,084 KB
testcase_09 AC 11 ms
5,888 KB
testcase_10 AC 11 ms
5,972 KB
testcase_11 AC 11 ms
5,904 KB
testcase_12 AC 11 ms
5,940 KB
testcase_13 AC 12 ms
5,888 KB
testcase_14 AC 11 ms
5,888 KB
testcase_15 AC 11 ms
6,144 KB
testcase_16 AC 11 ms
5,868 KB
testcase_17 AC 12 ms
6,028 KB
testcase_18 AC 11 ms
6,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding:utf-8 -*-

def calc(shiki):
	global nums
	stack = []
	ans = 0
	a = 0
	ope = "+"
	shiki+="*"
	for i in shiki:
		if i in nums:
			stack.append(int(i))
		else:
			keta = 1
			a = 0
			while len(stack) > 0:
				a += keta * stack.pop()
				keta *= 10
			if ope == "-":
				ans -= a
			else:
				ans += a
			ope = i
	return ans

if __name__ == "__main__":
	s = raw_input()
	nums = map(str,range(10))
	prev = s[len(s)-1]
	mx = -float("INF")
	for i in xrange(len(s)):
		if s[i] in nums and prev in nums:
			temp = s[i:len(s)] + s[0:i]
			mx = max(mx,calc(temp))
		prev = s[i]
	print mx
0