結果
| 問題 | 
                            No.1824 門\松\列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-05-14 17:00:00 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 667 ms / 2,000 ms | 
| コード長 | 384 bytes | 
| コンパイル時間 | 235 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 183,424 KB | 
| 最終ジャッジ日時 | 2024-07-23 02:56:14 | 
| 合計ジャッジ時間 | 2,860 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 | 
ソースコード
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]])
    print(dfs(t[i]))