結果

問題 No.1824 門\松\列
ユーザー ryusukeryusuke
提出日時 2022-01-28 22:43:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2023-08-28 21:11:41
合計ジャッジ時間 1,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,044 KB
testcase_01 AC 71 ms
71,284 KB
testcase_02 AC 92 ms
75,004 KB
testcase_03 AC 118 ms
77,312 KB
testcase_04 AC 90 ms
75,264 KB
権限があれば一括ダウンロードができます

ソースコード

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