結果

問題 No.265 数学のテスト
ユーザー damindamin
提出日時 2020-11-04 03:37:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,299 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 8,788 KB
最終ジャッジ日時 2023-09-29 15:29:02
合計ジャッジ時間 2,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 26 ms
8,356 KB
testcase_03 AC 29 ms
8,468 KB
testcase_04 AC 28 ms
8,536 KB
testcase_05 AC 31 ms
8,584 KB
testcase_06 AC 28 ms
8,464 KB
testcase_07 AC 31 ms
8,524 KB
testcase_08 AC 33 ms
8,540 KB
testcase_09 AC 27 ms
8,484 KB
testcase_10 AC 27 ms
8,484 KB
testcase_11 AC 32 ms
8,404 KB
testcase_12 AC 13 ms
8,412 KB
testcase_13 AC 20 ms
8,512 KB
testcase_14 AC 16 ms
8,376 KB
testcase_15 AC 13 ms
8,320 KB
testcase_16 AC 16 ms
8,332 KB
testcase_17 AC 14 ms
8,320 KB
testcase_18 AC 14 ms
8,380 KB
testcase_19 AC 14 ms
8,404 KB
testcase_20 AC 14 ms
8,352 KB
testcase_21 AC 14 ms
8,348 KB
testcase_22 AC 18 ms
8,140 KB
testcase_23 AC 14 ms
8,348 KB
testcase_24 AC 14 ms
8,308 KB
testcase_25 AC 20 ms
8,436 KB
testcase_26 AC 13 ms
8,344 KB
testcase_27 AC 13 ms
8,392 KB
testcase_28 AC 14 ms
8,324 KB
testcase_29 AC 13 ms
8,440 KB
testcase_30 AC 15 ms
8,332 KB
testcase_31 AC 14 ms
8,408 KB
testcase_32 AC 13 ms
8,260 KB
testcase_33 AC 15 ms
8,444 KB
testcase_34 AC 13 ms
8,548 KB
testcase_35 AC 16 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
try:
    import os
    f = open('input.txt', 'r')
    sys.stdin = f
except FileNotFoundError:
    None
from math import sqrt, ceil
input=lambda: sys.stdin.readline().strip()

n= int(input())
d=int(input())
s=input()
now=0
# ji = {i:0 for i in range(d+1)}

def gousei(di,dii):
    return {i:di[i]+dii[i] for i in range(d+1)}
def bibun(di):
    ans = {i:0 for i in range(d+1)}
    for i in range(d):
        ans[i] = di[i+1]*(i+1)
    ans[d]=0
    return ans
# print(gousei({0:3,1:2,2:4,3:0,},{0:2,1:2,2:4,3:4}))


def shin():
    global now
    ans = expr()
    while now<n and s[now]=="+":
        now+=1
        ans = gousei(ans,expr())
    # print(ans,now)
    return ans

def expr():
    global now
    # jitmp = {i:0 for i in range(d+1)}
    if s[now]=="d":
        now+=2
        jit = shin()
        now+=1
        return bibun(jit)
    else:
        return term()

def term():
    global now
    ji=0 ; kei=1
    ans = {i:0 for i in range(d+1)}
    if s[now]=="x":
        ji+=1
    else:
        kei*=int(s[now])
    now+=1
    while now< n and s[now]=="*":
        now+=1
        if s[now]=="x":
            ji+=1
            now+=1
        else:
            kei*=int(s[now])
            now+=1
    ans[ji]=kei
    return ans

last = shin()
print(*[last[i] for i in range(d+1)])
0