結果

問題 No.1618 Convolution?
ユーザー 草苺奶昔草苺奶昔
提出日時 2023-03-14 15:15:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 480 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 11,808 KB
実行使用メモリ 130,292 KB
最終ジャッジ日時 2023-10-18 11:42:05
合計ジャッジ時間 20,920 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 562 ms
42,296 KB
testcase_01 AC 455 ms
42,368 KB
testcase_02 AC 881 ms
79,764 KB
testcase_03 AC 946 ms
82,528 KB
testcase_04 WA -
testcase_05 AC 481 ms
43,040 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


def convolution(A, B):
    n, m = len(A), len(B)
    ph = 1 << (n + m - 2).bit_length()
    T = np.fft.rfft(A, ph) * np.fft.rfft(B, ph)
    res = np.fft.irfft(T, ph)[: n + m - 1]
    return np.rint(res).astype(np.int64)


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


A = [0] + A
B = [0] + B
f = list(range(n + 1))
A = convolution(A, f)
B = convolution(B, f)
C = [a + b for a, b in zip(A, B)]
C = C[1:]
print(*C)
0