結果

問題 No.1514 Squared Matching
ユーザー だれだれ
提出日時 2021-04-25 17:18:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,643 ms / 4,000 ms
コード長 777 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 467,796 KB
最終ジャッジ日時 2023-09-24 21:10:46
合計ジャッジ時間 31,590 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,260 KB
testcase_01 AC 1,634 ms
467,116 KB
testcase_02 AC 84 ms
75,544 KB
testcase_03 AC 72 ms
75,356 KB
testcase_04 AC 72 ms
75,220 KB
testcase_05 AC 77 ms
76,452 KB
testcase_06 AC 100 ms
82,240 KB
testcase_07 AC 373 ms
151,136 KB
testcase_08 AC 1,577 ms
453,316 KB
testcase_09 AC 1,389 ms
406,156 KB
testcase_10 AC 1,509 ms
433,468 KB
testcase_11 AC 1,552 ms
448,368 KB
testcase_12 AC 1,588 ms
458,748 KB
testcase_13 AC 1,599 ms
463,872 KB
testcase_14 AC 1,613 ms
465,832 KB
testcase_15 AC 1,602 ms
466,824 KB
testcase_16 AC 1,643 ms
467,168 KB
testcase_17 AC 1,614 ms
467,600 KB
testcase_18 AC 1,612 ms
467,684 KB
testcase_19 AC 1,607 ms
467,796 KB
testcase_20 AC 1,620 ms
467,272 KB
testcase_21 AC 1,607 ms
467,588 KB
testcase_22 AC 389 ms
154,588 KB
testcase_23 AC 711 ms
232,532 KB
testcase_24 AC 1,072 ms
311,340 KB
testcase_25 AC 1,403 ms
389,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import floor, sqrt
def main(n):
    ans = 0
    prime = [True] * (7500)
    x = [i for i in range(n + 1)]
    for i in range(4, 7500, 2):
        prime[i] = False
    j = 4
    while j <= n:
        k = j
        while k <= n:
            x[k] >>= 2
            k += j
        j *= 4
    i = 3
    while i * i < n:
        if prime[i]:
            w = i * i
            j = w

            while j * j <= n:
                prime[j] = False
                j += 2 * i

            j = w
            while j <= n:
                k = j
                while k <= n:
                    x[k] //= w
                    k += j
                j *= w
        i += 2
    for i in range(1, n + 1):
        ans += floor(sqrt(n / x[i]))
    print(ans)

n = int(input())
main(n)
0