結果

問題 No.1824 門\松\列
ユーザー ryusuke
提出日時 2022-01-28 22:43:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 1,846 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-12-30 09:11:47
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

ans = []
for _ in range(int(input())):
    n = int(input())
    # 中・小・大
    a = (n - 1) * n ** 2 // 2 - (n - 1) * n * (2 * n - 1) // 6 - n * (n - 1) + (n - 1) * n // 2
    # 中・大・小
    b = n ** 2 * (n - 1) // 2 - n * (n - 1) - (n - 1) * n * (2 * n - 1) // 6 + (n - 1) * n // 2
    # 大・小・中
    c = ((n - 2) * (n - 1) * (2 * n - 3) + 3 * ((n - 2) * (n - 1))) // 12
    # 小・大・中
    d = ((n - 2) * (n - 1) * (2 * n - 3) + 3 * ((n - 2) * (n - 1))) // 12
    #print('nabcd',n,max(0, a),max(0, b),max(0, c),max(0, d))

    ans.append(max(0, a) + max(0, b) + max(0, c) + max(0, d))
    #print(ans[-1])

print(*ans ,sep='\n')
0