結果
問題 | No.265 数学のテスト |
ユーザー |
![]() |
提出日時 | 2016-05-08 15:47:16 |
言語 | Python2 (2.7.18) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,132 bytes |
コンパイル時間 | 715 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 44,736 KB |
最終ジャッジ日時 | 2024-10-05 10:45:25 |
合計ジャッジ時間 | 7,040 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | TLE * 1 -- * 31 |
ソースコード
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