結果
| 問題 | 
                            No.1824 門\松\列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-05-14 16:50:53 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 359 bytes | 
| コンパイル時間 | 166 ms | 
| コンパイル使用メモリ | 82,696 KB | 
| 実行使用メモリ | 849,160 KB | 
| 最終ジャッジ日時 | 2024-07-23 02:45:56 | 
| 合計ジャッジ時間 | 5,756 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 1 | 
| other | MLE * 1 -- * 3 | 
ソースコード
import sys
sys.setrecursionlimit(10**7)
n = int(input())
t = [int(input()) for i in range(n)]
#print(t)
ans = [0]*(10**6+1)
ans[3] = 4
from functools import lru_cache
@lru_cache(maxsize=10**6+1)
def dfs(x):
    if ans[x] != 0:
        return ans[x]
    ans[x] += dfs(x-1)+(x-1)*(x-2)*2
    return ans[x]
dfs(10**6)
for i in range(n):
    print(ans[t[i]])