結果

問題 No.287 場合の数
ユーザー onakasuitacityonakasuitacity
提出日時 2020-10-17 14:59:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 1,122 bytes
コンパイル時間 1,024 ms
コンパイル使用メモリ 86,636 KB
実行使用メモリ 77,384 KB
最終ジャッジ日時 2023-09-28 08:02:48
合計ジャッジ時間 4,678 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
77,268 KB
testcase_01 AC 71 ms
71,588 KB
testcase_02 AC 79 ms
76,580 KB
testcase_03 AC 86 ms
77,192 KB
testcase_04 AC 87 ms
77,116 KB
testcase_05 AC 86 ms
77,108 KB
testcase_06 AC 80 ms
76,908 KB
testcase_07 AC 82 ms
77,028 KB
testcase_08 AC 88 ms
76,964 KB
testcase_09 AC 87 ms
77,384 KB
testcase_10 AC 87 ms
76,972 KB
testcase_11 AC 85 ms
76,928 KB
testcase_12 AC 89 ms
76,980 KB
testcase_13 AC 87 ms
76,884 KB
testcase_14 AC 83 ms
77,028 KB
testcase_15 AC 89 ms
76,960 KB
testcase_16 AC 82 ms
76,692 KB
testcase_17 AC 87 ms
77,172 KB
testcase_18 AC 81 ms
76,772 KB
testcase_19 AC 88 ms
77,100 KB
testcase_20 AC 86 ms
77,000 KB
testcase_21 AC 85 ms
77,104 KB
testcase_22 AC 89 ms
77,384 KB
testcase_23 AC 87 ms
77,016 KB
testcase_24 AC 82 ms
76,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = int(input())
    f = [1] * (n + 1)
    for _ in range(3):
        f = convolution(f, f)
    print(round(f[6 * n].real))
resolve()
0