結果

問題 No.265 数学のテスト
ユーザー matsu7874matsu7874
提出日時 2015-08-07 23:38:11
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 8,456 KB
最終ジャッジ日時 2023-08-16 02:02:51
合計ジャッジ時間 1,961 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,324 KB
testcase_01 AC 18 ms
8,404 KB
testcase_02 AC 21 ms
8,412 KB
testcase_03 AC 17 ms
8,332 KB
testcase_04 AC 18 ms
8,332 KB
testcase_05 AC 19 ms
8,316 KB
testcase_06 AC 18 ms
8,336 KB
testcase_07 AC 19 ms
8,456 KB
testcase_08 AC 20 ms
8,392 KB
testcase_09 AC 17 ms
8,296 KB
testcase_10 AC 18 ms
8,284 KB
testcase_11 AC 19 ms
8,388 KB
testcase_12 AC 14 ms
7,936 KB
testcase_13 AC 15 ms
8,316 KB
testcase_14 AC 15 ms
7,828 KB
testcase_15 AC 13 ms
7,788 KB
testcase_16 AC 14 ms
8,256 KB
testcase_17 AC 13 ms
7,860 KB
testcase_18 AC 14 ms
7,816 KB
testcase_19 AC 13 ms
7,868 KB
testcase_20 AC 13 ms
7,868 KB
testcase_21 AC 14 ms
7,860 KB
testcase_22 AC 15 ms
8,336 KB
testcase_23 AC 15 ms
7,900 KB
testcase_24 AC 15 ms
7,820 KB
testcase_25 AC 17 ms
8,252 KB
testcase_26 AC 14 ms
7,816 KB
testcase_27 AC 13 ms
7,836 KB
testcase_28 AC 14 ms
7,820 KB
testcase_29 AC 13 ms
7,868 KB
testcase_30 AC 13 ms
7,780 KB
testcase_31 AC 13 ms
7,860 KB
testcase_32 AC 14 ms
7,828 KB
testcase_33 AC 14 ms
7,816 KB
testcase_34 AC 13 ms
7,848 KB
testcase_35 AC 14 ms
7,840 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 = int(s)
            else:
                a *= int(s)
        elif s == '{':
            d_cnt += 1
        elif s == '}':
            if x_cnt >= d_cnt:
                A[x_cnt-d_cnt] += a*bibun(x_cnt, d_cnt)
            x_cnt = 0
            a = 0
            d_cnt -= 1
        elif s == '+':
            if x_cnt >= d_cnt:
                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