結果
| 問題 |
No.265 数学のテスト
|
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2021-08-31 19:59:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 1,341 bytes |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 71,680 KB |
| 最終ジャッジ日時 | 2024-11-26 02:34:58 |
| 合計ジャッジ時間 | 3,296 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
N = I()
d = I()
S = S()
def der(n,m): # x^nのm階微分
if n < m:
return 0,0
res = 1
for i in range(m):
res *= n-i
return n-m,res
ANS = [0]*(d+1)
count = 0 # 何階微分か
idx = 0
while idx < N:
s = S[idx]
if s == 'd':
count += 1
idx += 2
elif s == '}':
count -= 1
idx += 1
elif s == '+':
idx += 1
else:
coefficient = 1
power = 0
for j in range(idx,N):
s = S[j]
if s.isdigit():
coefficient = int(s)
elif s == 'x':
power += 1
elif s == '*':
continue
elif s == '+':
idx = j+1
break
else:
idx = j
break
else:
idx = N
e,c = der(power,count)
ANS[e] += coefficient*c
print(*ANS)
ayaoni