結果

問題 No.265 数学のテスト
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-08 15:47:16
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 1,132 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 7,072 KB
実行使用メモリ 42,040 KB
最終ジャッジ日時 2024-04-15 13:51:56
合計ジャッジ時間 6,515 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
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 #

N=int(raw_input())
d=int(raw_input())
S=raw_input()

def rec(S,d):
    ans=[0 for i in range(d+1)]
    start=0
    while start<len(S):
        if S[start]=='d':
            cnt,end=1,start+2
            while True:
                if S[end]=='{':
                    cnt+=1
                elif S[end]=='}':
                    cnt-=1
                    if cnt==0:
                        break
                end+=1
            ans2=rec(S[start+2:end],d)
            for di in range(d):
                ans2[di]=ans2[di+1]*(di+1)
            ans2[d]=0
            ans=[x+y for (x,y) in zip(ans,ans2)]
            start=end+2
        else:
            cnt,coef,end=0,1,start
            while end<len(S):
                if S[end]=='+':
                    break
                elif S[end]=='x':
                    cnt+=1
                elif S[end]>='0' and S[end]<='9':
                    coef=int(S[end])
                end+=1
            ans2=[0 for i in range(d+1)]
            ans2[cnt]=coef
            ans=[x+y for (x,y) in zip(ans,ans2)]
            start=end+1
    return ans

for a in rec(S,d):
    print a,
print

0