結果

問題 No.265 数学のテスト
ユーザー matsu7874matsu7874
提出日時 2015-08-07 23:20:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 963 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 8,508 KB
最終ジャッジ日時 2023-09-25 06:22:46
合計ジャッジ時間 2,403 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 16 ms
7,820 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 16 ms
7,836 KB
testcase_19 WA -
testcase_20 RE -
testcase_21 AC 15 ms
7,820 KB
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 AC 15 ms
7,900 KB
testcase_27 WA -
testcase_28 RE -
testcase_29 AC 15 ms
7,924 KB
testcase_30 RE -
testcase_31 WA -
testcase_32 AC 16 ms
7,868 KB
testcase_33 WA -
testcase_34 AC 15 ms
7,944 KB
testcase_35 AC 16 ms
7,784 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':
            a *= int(s)
        elif s == '{':
            d_cnt += 1
        elif s == '}':
            A[x_cnt-d_cnt] += a*bibun(x_cnt, d_cnt)
            x_cnt = 0
            a = 0
            d_cnt -= 1
        elif s == '*':
            pass
        elif s == '+':
            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
    A[x_cnt] += a * bibun(x_cnt, d_cnt)
    x_cnt = 0
    a = 1

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





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