結果

問題 No.193 筒の数式
ユーザー 👑 yumechiyumechi
提出日時 2015-04-27 00:55:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 1,000 ms
コード長 1,005 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 7,916 KB
最終ジャッジ日時 2023-09-18 12:35:20
合計ジャッジ時間 1,263 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,800 KB
testcase_01 AC 16 ms
7,824 KB
testcase_02 AC 16 ms
7,792 KB
testcase_03 AC 15 ms
7,888 KB
testcase_04 AC 15 ms
7,856 KB
testcase_05 AC 15 ms
7,776 KB
testcase_06 AC 14 ms
7,852 KB
testcase_07 AC 15 ms
7,824 KB
testcase_08 AC 15 ms
7,852 KB
testcase_09 AC 15 ms
7,884 KB
testcase_10 AC 15 ms
7,808 KB
testcase_11 AC 15 ms
7,916 KB
testcase_12 AC 15 ms
7,852 KB
testcase_13 AC 15 ms
7,752 KB
testcase_14 AC 15 ms
7,816 KB
testcase_15 AC 15 ms
7,828 KB
testcase_16 AC 15 ms
7,832 KB
testcase_17 AC 15 ms
7,812 KB
testcase_18 AC 15 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
maxnum = -9999999999999999999999999
length = len(S)
checknum = lambda x, line: not (line[x] == "+" or line[x] == "-")
for i in range(length):
    line = S[i:length] + S[0:i]
    tline = line

    if not checknum(0, line) or not checknum(len(line) - 1, line):
        continue
    
    j = 0
    while tline[j] == "0":
        j += 1
    if not checknum(j, tline):
        tline = tline[j - 1:len(tline)]
        
    j = 1
    while j < len(tline):
        if not checknum(j - 1, tline) and tline[j] == "0":
            if j == len(tline) - 1:
                break
            else:
                if checknum(j + 1, tline):
                    tline = tline[0:j] + tline[j+1:len(tline)]
        else:
            j += 1

    for i in range(len(tline) - 1):
        if not checknum(i, tline) and not checknum(i + 1, tline):
            line = ""
            break
    else:
        line = tline

    try:
        maxnum = max(maxnum, eval(line))
    except:
        pass
print(maxnum)
     
0