結果

問題 No.265 数学のテスト
ユーザー nebukuro09
提出日時 2016-10-25 23:29:25
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 556 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-11-24 03:45:07
合計ジャッジ時間 4,998 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
d = input()
S = filter(None, raw_input().replace('+', ' ').replace('d{', ' { ').replace('}', ' } ').split())
coef = [0 for i in xrange(d+1)]
dx = 0

for s in S:
    if s == '{':
        dx += 1
    elif s == '}':
        dx -= 1
    else:
        t = sorted(s.split('*'))
        if t[0].isdigit():
            c = int(t[0])
            t.pop(0)
        else:
            c = 1
        for i in xrange(len(t), len(t)-dx, -1):
            c *= i
        e = len(t) - dx
        if e >= 0:
            coef[e] += c
print ' '.join(map(str, coef))
0