結果

問題 No.1618 Convolution?
ユーザー IgrmiIgrmi
提出日時 2021-07-22 21:47:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 96,980 KB
最終ジャッジ日時 2023-09-24 16:24:59
合計ジャッジ時間 15,738 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,612 KB
testcase_01 AC 134 ms
29,812 KB
testcase_02 AC 582 ms
74,964 KB
testcase_03 AC 659 ms
76,352 KB
testcase_04 WA -
testcase_05 AC 162 ms
33,372 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
def convolve(f, g):
    fft_len = 1
    while 2 * fft_len < len(f) + len(g) - 1:
        fft_len *= 2
    fft_len *= 2
    Ff = numpy.fft.rfft(f, fft_len)
    Fg = numpy.fft.rfft(g, fft_len)
    Fh = Ff * Fg
    h = numpy.fft.irfft(Fh, fft_len)
    h = numpy.rint(h).astype(numpy.int64)
    return h[:len(f) + len(g) - 1]

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AB = [A[i] + B[i] for i in range(N)]
D = [i for i in range(1, N + 1)]
print(0, *convolve(AB, D))
0