結果

問題 No.2174 3 O'clock Easy
ユーザー dolpdolp
提出日時 2022-12-22 11:54:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 331 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 53,880 KB
最終ジャッジ日時 2024-05-01 06:00:30
合計ジャッジ時間 1,247 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,612 KB
testcase_01 AC 40 ms
52,464 KB
testcase_02 AC 37 ms
52,012 KB
testcase_03 AC 38 ms
53,880 KB
testcase_04 AC 38 ms
52,068 KB
testcase_05 AC 37 ms
52,836 KB
testcase_06 AC 37 ms
52,664 KB
testcase_07 AC 37 ms
53,076 KB
testcase_08 AC 38 ms
53,128 KB
testcase_09 AC 36 ms
52,976 KB
testcase_10 AC 37 ms
52,836 KB
testcase_11 AC 37 ms
52,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def one(n):
    k=n//3
    return 3*k*(k+1)//2-2*k
def two(n):
    k=n//3
    return 3*k*(k+1)*(2*k+1)//2-3*k*(k+1)+k
def three(n):
    k=n//3
    return 27*(k*(k+1)//2)**2

N=int(input())
if N%3==0:
    print(one(N)+two(N)+three(N))
elif N%3==1:
    print(one(N)+two(N)+three(N)+N)
else:
    print(one(N)+two(N)+three(N)+N+N**2-1)
0