結果

問題 No.1824 門\松\列
ユーザー ryusukeryusuke
提出日時 2022-01-28 22:43:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 77,400 KB
最終ジャッジ日時 2023-08-28 21:13:10
合計ジャッジ時間 1,669 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,400 KB
testcase_01 AC 75 ms
71,308 KB
testcase_02 AC 92 ms
75,592 KB
testcase_03 AC 112 ms
77,400 KB
testcase_04 AC 96 ms
75,524 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

    ans.append(max(0, a) + max(0, b) + max(0, c) + max(0, d))

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