結果
| 問題 | 
                            No.93 ペガサス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             maspy
                         | 
                    
| 提出日時 | 2020-04-23 17:18:59 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 481 ms / 5,000 ms | 
| コード長 | 1,064 bytes | 
| コンパイル時間 | 136 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 44,536 KB | 
| 最終ジャッジ日時 | 2024-10-13 16:53:44 | 
| 合計ジャッジ時間 | 11,686 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 7
N = int(read())
if N == 1:
    print(1)
    exit()
M = N // 2
def update_dp(f, g):
    newf = np.zeros(len(f) + 1, np.int64)
    newg = newf.copy()
    newg[:-1] = f + f + g
    newf[1:] = f + g
    newf %= MOD
    newg %= MOD
    return newf, newg
f = np.array([0, 1], np.int64)
g = np.array([0, 0], np.int64)
for _ in range((N - 2) // 2):
    f, g = update_dp(f, g)
A = f + g
if N & 1:
    f, g = update_dp(f, g)
B = f + g
def convolve(A, B):
    A1, A2 = divmod(A, 1 << 16)
    B1, B2 = divmod(B, 1 << 16)
    X = np.convolve(A1, B1) % MOD
    Z = np.convolve(A2, B2) % MOD
    Y = (np.convolve(A1 + A2, B1 + B2) - X - Z) % MOD
    return ((X << 32) + (Y << 16) + Z) % MOD
A = convolve(A, B)
fact = [1, 1]
for n in range(2, N + 10):
    fact.append(fact[-1] * n % MOD)
fact = np.array(fact, dtype=np.int64)
A *= fact[:N+1]
A[1 - (N & 1)::2] *= - 1
A %= MOD
answer = A.sum() % MOD
print(answer)
            
            
            
        
            
maspy