結果

問題 No.1514 Squared Matching
ユーザー rlangevinrlangevin
提出日時 2023-08-31 12:17:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,342 ms / 4,000 ms
コード長 598 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 467,792 KB
最終ジャッジ日時 2023-08-31 12:18:30
合計ジャッジ時間 35,167 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,492 KB
testcase_01 AC 2,342 ms
467,632 KB
testcase_02 AC 238 ms
71,064 KB
testcase_03 AC 73 ms
70,888 KB
testcase_04 AC 71 ms
71,096 KB
testcase_05 AC 96 ms
76,112 KB
testcase_06 AC 105 ms
82,028 KB
testcase_07 AC 409 ms
151,220 KB
testcase_08 AC 1,813 ms
453,492 KB
testcase_09 AC 1,602 ms
406,228 KB
testcase_10 AC 1,724 ms
433,568 KB
testcase_11 AC 1,782 ms
448,484 KB
testcase_12 AC 1,839 ms
458,708 KB
testcase_13 AC 1,852 ms
463,808 KB
testcase_14 AC 1,874 ms
465,972 KB
testcase_15 AC 1,869 ms
467,032 KB
testcase_16 AC 1,893 ms
467,400 KB
testcase_17 AC 1,852 ms
467,680 KB
testcase_18 AC 1,890 ms
467,768 KB
testcase_19 AC 1,862 ms
467,792 KB
testcase_20 AC 1,899 ms
467,644 KB
testcase_21 AC 1,889 ms
467,492 KB
testcase_22 AC 431 ms
154,668 KB
testcase_23 AC 764 ms
232,728 KB
testcase_24 AC 1,126 ms
311,520 KB
testcase_25 AC 1,507 ms
389,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt, ceil, floor


def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S

N = int(input())

P = Sieve(int(sqrt(N)) + 10)
L = list(range(N + 1))
for p in P:
    now = p * p
    while now <= N:
        for i in range(now, N + 1, now):
            L[i] //= p * p
        now *= p * p

ans = 0
for i in range(1, N + 1):
    ans += floor(sqrt(N//L[i]))

print(ans)
0