結果
問題 |
No.265 数学のテスト
|
ユーザー |
![]() |
提出日時 | 2020-03-22 03:36:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 676 ms / 2,000 ms |
コード長 | 931 bytes |
コンパイル時間 | 129 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 44,432 KB |
最終ジャッジ日時 | 2024-12-24 11:24:39 |
合計ジャッジ時間 | 23,254 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) D = int(readline()) S = read().rstrip().decode() import numpy as np def der(f): g = np.zeros_like(f) g[:-1] = f[1:] * np.arange(1, len(f)) return g S = S.replace('d{', ' d{ ').replace('}', ' } ').replace('+', ' + ').split() depth = 0 answer = np.zeros(D + 1, np.int64) for word in S: if word == '+': continue if word == 'd{': depth += 1 continue if word == '}': depth -= 1 continue if depth > D: continue coef = 1 deg = 0 terms = word.split('*') for t in terms: if t == 'x': deg += 1 else: coef = int(t) f = np.zeros(D + 1, np.int64) f[deg] = coef for _ in range(depth): f = der(f) answer += f print(*answer)