結果

問題 No.265 数学のテスト
ユーザー matsu7874matsu7874
提出日時 2015-08-07 23:27:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,279 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 8,516 KB
最終ジャッジ日時 2023-09-25 06:24:55
合計ジャッジ時間 2,043 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,444 KB
testcase_01 RE -
testcase_02 AC 26 ms
8,444 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 16 ms
8,208 KB
testcase_16 RE -
testcase_17 AC 16 ms
8,152 KB
testcase_18 AC 15 ms
8,328 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 15 ms
8,288 KB
testcase_22 RE -
testcase_23 AC 16 ms
8,348 KB
testcase_24 AC 16 ms
8,236 KB
testcase_25 RE -
testcase_26 AC 16 ms
8,300 KB
testcase_27 WA -
testcase_28 RE -
testcase_29 AC 16 ms
8,276 KB
testcase_30 RE -
testcase_31 AC 15 ms
8,404 KB
testcase_32 AC 16 ms
8,208 KB
testcase_33 AC 16 ms
8,232 KB
testcase_34 AC 15 ms
8,232 KB
testcase_35 AC 16 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def bibun(n,c):
    if n<c:
        return 0
    res = 1
    for i in range(c):
        res *= n
        n -= 1
    return res

def main():
    N = int(input())
    d = int(input())
    S = input()
    A = [0 for i in range(d+1)]
    d_cnt = 0
    x_cnt = 0
    a = 0
    pre = ''
    for s in S:
        if s in '123456789':
            if a==0:
                a=1
            a *= int(s)
        elif s == '{':
            d_cnt += 1
        elif s == '}':
            if x_cnt < d_cnt:
                x_cnt = 0
                a = 0
                d_cnt -= 1
                continue
            A[x_cnt-d_cnt] += a*bibun(x_cnt, d_cnt)
            x_cnt = 0
            a = 0
            d_cnt -= 1
        elif s == '*':
            pass
        elif s == '+':
            if x_cnt < d_cnt:
                x_cnt = 0
                a = 0
                d_cnt -= 1
                continue
            A[x_cnt-d_cnt] += a*bibun(x_cnt, d_cnt)
            x_cnt = 0
            a = 0
        elif s == 'x':
            x_cnt += 1
            if a == 0:
                a = 1
    if x_cnt >= d_cnt:
        A[x_cnt - d_cnt] += a * bibun(x_cnt, d_cnt)

    ans = ''
    for ai in A:
        ans += str(ai) + ' '
    print(ans[:-1])





if __name__ == '__main__':
    main()
0