結果

問題 No.265 数学のテスト
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-08 15:49:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,186 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 6,720 KB
実行使用メモリ 6,512 KB
最終ジャッジ日時 2023-08-16 02:09:29
合計ジャッジ時間 2,574 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
6,512 KB
testcase_01 AC 76 ms
6,376 KB
testcase_02 AC 79 ms
6,340 KB
testcase_03 AC 60 ms
6,088 KB
testcase_04 AC 60 ms
5,972 KB
testcase_05 AC 66 ms
6,100 KB
testcase_06 AC 57 ms
6,184 KB
testcase_07 AC 67 ms
6,112 KB
testcase_08 AC 76 ms
6,008 KB
testcase_09 AC 52 ms
6,168 KB
testcase_10 AC 55 ms
6,168 KB
testcase_11 AC 62 ms
6,036 KB
testcase_12 AC 10 ms
5,888 KB
testcase_13 AC 27 ms
5,912 KB
testcase_14 AC 21 ms
6,008 KB
testcase_15 AC 10 ms
5,936 KB
testcase_16 AC 15 ms
6,064 KB
testcase_17 AC 10 ms
6,020 KB
testcase_18 AC 10 ms
5,960 KB
testcase_19 AC 10 ms
5,988 KB
testcase_20 AC 10 ms
5,892 KB
testcase_21 AC 9 ms
6,124 KB
testcase_22 AC 21 ms
6,092 KB
testcase_23 AC 9 ms
5,940 KB
testcase_24 AC 10 ms
6,072 KB
testcase_25 AC 35 ms
6,048 KB
testcase_26 AC 9 ms
5,940 KB
testcase_27 AC 10 ms
5,852 KB
testcase_28 AC 13 ms
6,016 KB
testcase_29 AC 10 ms
6,108 KB
testcase_30 AC 13 ms
5,892 KB
testcase_31 AC 10 ms
5,856 KB
testcase_32 AC 9 ms
6,080 KB
testcase_33 AC 9 ms
6,120 KB
testcase_34 AC 10 ms
5,856 KB
testcase_35 AC 10 ms
5,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def rec(S,d,depth):
    ans=[0 for i in range(d+1)]
    if depth > 10:
        return ans
    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,depth+1)
            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,0):
    print a,
print

0