結果

問題 No.2249 GCDistance
ユーザー hir355hir355
提出日時 2023-03-17 22:20:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,923 ms / 5,000 ms
コード長 293 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 154,568 KB
最終ジャッジ日時 2023-10-18 15:16:15
合計ジャッジ時間 23,172 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,417 ms
153,432 KB
testcase_01 AC 1,870 ms
154,568 KB
testcase_02 AC 1,902 ms
154,568 KB
testcase_03 AC 1,878 ms
154,568 KB
testcase_04 AC 1,601 ms
154,568 KB
testcase_05 AC 1,900 ms
154,568 KB
testcase_06 AC 1,903 ms
154,568 KB
testcase_07 AC 1,923 ms
154,568 KB
testcase_08 AC 1,447 ms
154,336 KB
testcase_09 AC 1,882 ms
154,568 KB
testcase_10 AC 1,808 ms
154,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M = 10000000
t = int(input())
e = [i for i in range(M + 1)]
for i in range(2, M + 1):
    if e[i] == i:
        for j in range(i, M + 1, i):
            e[j] = e[j] // i * (i - 1)
for i in range(M):
    e[i + 1] += e[i]
for _ in range(t):
    n = int(input())
    print(n * (n - 1) - e[n] + 1)
0