結果

問題 No.1618 Convolution?
ユーザー tktk_snsntktk_snsn
提出日時 2021-09-20 20:06:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 76,872 KB
最終ジャッジ日時 2023-09-15 16:13:37
合計ジャッジ時間 11,972 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
29,612 KB
testcase_01 AC 126 ms
29,800 KB
testcase_02 AC 567 ms
73,864 KB
testcase_03 AC 622 ms
75,936 KB
testcase_04 WA -
testcase_05 AC 156 ms
32,728 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 conv(X, Y):
    N = len(X) + len(Y) - 1
    sz = 1 << (N - 1).bit_length()
    Cx = np.fft.rfft(X, sz)
    Cy = np.fft.rfft(Y, sz)
    Z = np.fft.irfft(Cx * Cy, sz)[:N]
    return np.rint(Z).astype(np.int64)


N = int(input())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.arange(N+1)
ans = conv(A, C) + conv(B, C)
print(*ans)
0