結果

問題 No.193 筒の数式
コンテスト
ユーザー 💕💖💞
提出日時 2018-08-10 22:42:47
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 106 ms / 1,000 ms
+ 255µs
コード長 545 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 296 ms
コンパイル使用メモリ 21,468 KB
実行使用メモリ 15,788 KB
最終ジャッジ日時 2026-09-03 00:17:49
合計ジャッジ時間 3,845 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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