提出 #44629254


ソースコード 拡げる

n, m = map(int, input().split())
a = list(map(int, input().split())) # n 次多項式
c = list(map(int, input().split())) # n + m 次多項式
dp = [None for _ in range(m + 1)] # m 次多項式
dp[m] = c[m + n] // a[n]
for i in reversed(range(n + m)):# cの係数
    tmp = 0
    for j in reversed(range(i + 1)):
        p = j # bの係数
        q = i - p # aの係数
        if 0 <= p <= m and 0 <= q <= n:
            if dp[p] == None:
                if a[q] != 0:
                    # print(tmp, a[q])
                    dp[p] = (c[i] - tmp) // a[q]
                    break
                else:
                    dp[p] = 0
                    break
            else:
                tmp += dp[p] * a[q]
        # print(i, j, p, q, dp, tmp)
print(*dp)

提出情報

提出日時
問題 D - Polynomial division
ユーザ harry_arbrebleu
言語 PyPy3 (7.3.0)
得点 400
コード長 788 Byte
結果 AC
実行時間 184 ms
メモリ 65760 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 20
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 184 ms 61472 KiB
example_01.txt AC 53 ms 61384 KiB
hand_00.txt AC 60 ms 65680 KiB
hand_01.txt AC 58 ms 65528 KiB
hand_02.txt AC 53 ms 62064 KiB
hand_03.txt AC 54 ms 61868 KiB
hand_04.txt AC 59 ms 65476 KiB
hand_05.txt AC 50 ms 61592 KiB
random_00.txt AC 56 ms 65608 KiB
random_01.txt AC 59 ms 65472 KiB
random_02.txt AC 56 ms 65604 KiB
random_03.txt AC 57 ms 65584 KiB
random_04.txt AC 56 ms 65760 KiB
random_05.txt AC 57 ms 65488 KiB
random_06.txt AC 56 ms 65660 KiB
random_07.txt AC 59 ms 65372 KiB
random_08.txt AC 56 ms 65440 KiB
random_09.txt AC 57 ms 65624 KiB
random_10.txt AC 57 ms 65364 KiB
random_11.txt AC 55 ms 65584 KiB