結果

問題 No.2249 GCDistance
ユーザー lloyzlloyz
提出日時 2023-07-28 21:09:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,624 ms / 5,000 ms
コード長 363 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 154,880 KB
最終ジャッジ日時 2024-04-16 04:56:29
合計ジャッジ時間 22,208 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,505 ms
153,984 KB
testcase_01 AC 1,617 ms
154,496 KB
testcase_02 AC 1,624 ms
154,624 KB
testcase_03 AC 1,594 ms
154,496 KB
testcase_04 AC 1,539 ms
154,240 KB
testcase_05 AC 1,606 ms
154,624 KB
testcase_06 AC 1,613 ms
154,880 KB
testcase_07 AC 1,620 ms
154,496 KB
testcase_08 AC 1,513 ms
154,496 KB
testcase_09 AC 1,603 ms
154,368 KB
testcase_10 AC 1,607 ms
154,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

m = 10**7
P = list(range(m + 1))
for i in range(2, m + 1):
    if P[i] == i:
        for j in range(i, m + 1, i):
            P[j] = P[j] // i * (i - 1)
for i in range(2, m + 1):
    P[i] += P[i - 1]
for _ in range(int(input())):
    n = int(input())
    a, b = n * (n - 1) // 2, P[n] - 1
    c = a - b
    print(b + 2 * c)
0