結果

問題 No.1824 門\松\列
ユーザー ryusukeryusuke
提出日時 2022-01-28 22:49:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 78,524 KB
最終ジャッジ日時 2023-08-28 21:23:49
合計ジャッジ時間 1,626 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,064 KB
testcase_01 AC 78 ms
71,132 KB
testcase_02 AC 100 ms
76,144 KB
testcase_03 AC 134 ms
78,524 KB
testcase_04 AC 98 ms
76,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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(max(0, a) + max(0, b) + max(0, c) + max(0, d))
0