結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2020-10-17 15:14:15 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,164 bytes |
コンパイル時間 | 959 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 291,164 KB |
最終ジャッジ日時 | 2024-07-21 02:37:44 |
合計ジャッジ時間 | 27,638 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 RE * 5 |
ソースコード
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() from cmath import pi, rect def _fft(A, inverse = False): N = len(A) logN = (N - 1).bit_length() step = N for k in range(logN): step >>= 1 w = rect(1, pi / (1 << k) * (1 - 2 * inverse)) wj = 1 nA = [0] * N for j in range(1 << k): for i in range(1 << logN - k - 1): s, t = i + j * step, i + j * step + (N >> 1) ps, pt = i + j * step * 2, i + j * step * 2 + step nA[s], nA[t] = A[ps] + A[pt] * wj, A[ps] - A[pt] * wj wj *= w A = nA return A def convolution(f, g): N = 1 << (len(f) + len(g) - 2).bit_length() Ff, Fg = _fft(f + [0] * (N - len(f))), _fft(g + [0] * (N - len(g))) fg = _fft([a * b / N for a, b in zip(Ff, Fg)], inverse = True) del fg[len(f) + len(g) - 1:] return fg def resolve(): n, x = map(int, input().split()) f = [0] * 100001 for a in map(int, input().split()): f[a] += 1 f = convolution(f, f) print(round(f[x].real)) resolve()