結果

問題 No.265 数学のテスト
ユーザー mkawa2mkawa2
提出日時 2020-01-31 14:15:34
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,243 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 839,680 KB
最終ジャッジ日時 2023-10-17 08:19:42
合計ジャッジ時間 6,595 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]

def main():
    def cal(s):
        res = [0] * (d + 1)
        i = 0
        inpar = 0   # いくつのd{}に囲まれているか
        isone=True  # 単項式かどうか
        for j,c in enumerate(s):
            if c==43 and inpar==0:
                ret = cal(s[i:j])
                for k in range(d + 1): res[k] += ret[k]
                i = j + 1
                isone=False
            if c == 123: inpar += 1
            if c == 125: inpar -= 1
        if isone:
            # 微分のとき
            if s[0] == 100:
                ret = cal(s[2:-1])
                for i, a in enumerate(ret[1:], 1):
                    res[i - 1] = a * i
            # 累乗の計算のとき
            else:
                a = 1
                x = 0
                for c in s:
                    if 48 <= c <= 57: a = c - 48
                    if c == 120: x += 1
                res[x] = a
        else:
            ret = cal(s[i:])
            for k in range(d + 1): res[k] += ret[k]
        return res

    n = II()
    d = II()
    s = SI()
    s=[ord(c) for c in s]
    print(*cal(s))

main()
0