結果

問題 No.265 数学のテスト
ユーザー とりゐとりゐ
提出日時 2023-06-06 14:45:59
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 962 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 86,656 KB
実行使用メモリ 84,152 KB
最終ジャッジ日時 2023-08-28 10:42:19
合計ジャッジ時間 6,183 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 131 ms
77,996 KB
testcase_03 AC 179 ms
80,788 KB
testcase_04 AC 172 ms
79,504 KB
testcase_05 AC 181 ms
79,540 KB
testcase_06 AC 155 ms
78,704 KB
testcase_07 AC 156 ms
79,864 KB
testcase_08 AC 196 ms
81,724 KB
testcase_09 AC 170 ms
79,384 KB
testcase_10 AC 156 ms
80,312 KB
testcase_11 AC 178 ms
79,356 KB
testcase_12 AC 75 ms
75,996 KB
testcase_13 AC 127 ms
78,752 KB
testcase_14 AC 108 ms
77,448 KB
testcase_15 AC 71 ms
71,224 KB
testcase_16 AC 92 ms
76,300 KB
testcase_17 AC 71 ms
71,404 KB
testcase_18 AC 71 ms
71,252 KB
testcase_19 AC 78 ms
75,900 KB
testcase_20 AC 72 ms
71,316 KB
testcase_21 AC 73 ms
71,292 KB
testcase_22 AC 108 ms
77,276 KB
testcase_23 AC 70 ms
71,012 KB
testcase_24 AC 72 ms
71,292 KB
testcase_25 AC 143 ms
78,772 KB
testcase_26 AC 76 ms
75,780 KB
testcase_27 AC 70 ms
71,148 KB
testcase_28 AC 84 ms
76,084 KB
testcase_29 AC 75 ms
75,112 KB
testcase_30 AC 78 ms
74,776 KB
testcase_31 AC 71 ms
71,308 KB
testcase_32 AC 73 ms
71,256 KB
testcase_33 AC 73 ms
71,328 KB
testcase_34 AC 71 ms
71,332 KB
testcase_35 AC 73 ms
71,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
d=int(input())
s=input()

def number(s):
  global i
  res=[0]*(d+1)
  if '0'<=s[i]<='9':
    res[0]=int(s[i])
    i+=1
  elif s[i]=='x':
    res[1]=1
    i+=1
  return res

def add(x,y):
  z=[0]*(d+1)
  for j in range(d+1):
    z[j]=x[j]+y[j]
  return z

def differential(x):
  y=[0]*(d+1)
  for j in range(1,d+1):
    y[j-1]=x[j]*j
  return y

def prod(x,y):
  z=[0]*(d+1)
  for j in range(d+1):
    for k in range(d+1):
      if j+k<=d:
        z[j+k]+=x[j]*y[k]
  return z

def expr(s):
  global i
  res=term(s)
  while i<len(s):
    if s[i]=='+':
      i+=1
      res=add(res,term(s))
    else:
      break
  return res

def term(s):
  global i
  res=factor(s)
  while i<len(s):
    if s[i]=='*':
      i+=1
      res=prod(res,factor(s))
    else:
      return res
  return res

def factor(s):
  global i
  if s[i]=='d':
    i+=2
    res=expr(s)
    if s[i]=='}':
      i+=1
    return differential(res)
  return number(s)

i=0
print(*expr(s))
0