結果

問題 No.193 筒の数式
コンテスト
ユーザー 💕💖💞
提出日時 2018-08-10 22:42:47
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 31 ms / 1,000 ms
+ 746µs
コード長 545 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 81 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2026-10-14 18:15:27
合計ジャッジ時間 2,392 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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