結果

問題 No.193 筒の数式
ユーザー 💕💖💞
提出日時 2018-08-10 22:42:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 545 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-09-23 05:58:15
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

def stack_machine(ss):
  ss = re.sub(r'^0{1,}', '', ss) 
  s = [ss[0]]
  for snext in ss[1:-1]:
    if s[-1] in ['+', '-'] and snext == '0':
      continue
    s.append( snext )
  s.append( ss[-1] )
  #print(s)
  return ''.join(s)

s = input()
import copy
import re
ss = [ s ]
ans = []
for i in range(len(s)):
  ss.append( ss[-1][1:] + ss[-1][0] )
  if ss[-1][0] not in ['+', '-'] and ss[-1][-1] not in ['+', '-']:
    ss_1 = stack_machine(ss[-1])
    #print(ss[-1], ss_1)
    try:
      ans.append( eval(ss_1) )
    except: ...
print(max(ans))
0