結果

問題 No.2249 GCDistance
ユーザー ああいいああいい
提出日時 2023-03-18 21:13:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,063 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,684 KB
実行使用メモリ 268,024 KB
最終ジャッジ日時 2023-10-18 17:34:33
合計ジャッジ時間 25,124 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,532 ms
232,152 KB
testcase_01 AC 2,036 ms
268,012 KB
testcase_02 AC 2,035 ms
268,008 KB
testcase_03 AC 2,037 ms
267,988 KB
testcase_04 AC 1,729 ms
247,308 KB
testcase_05 AC 2,027 ms
268,016 KB
testcase_06 AC 1,994 ms
268,024 KB
testcase_07 AC 2,025 ms
268,016 KB
testcase_08 AC 1,637 ms
233,580 KB
testcase_09 AC 2,009 ms
268,020 KB
testcase_10 AC 2,063 ms
262,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

from collections import defaultdict
d = defaultdict(list)
for i in range(T):
    N = int(input())
    d[N].append(i)

ans = [0] * T
C = 10 ** 7
dat = list(range(C + 1))
era = [0] * (C + 1)
tmp = 0
for i in range(2,C + 1):
    if era[i] == 0:
        for j in range(i,C + 1,i):
            era[j] = 1
            dat[j] //= i
            dat[j] *= (i-1)
for i in range(2,C + 1):
    tmp += dat[i] + (i - 1 - dat[i]) * 2
    if i in d:
        for j in d[i]:
            ans[j] = tmp
print(*ans,sep = "\n")
#print(dat)
0