結果

問題 No.1653 Squarefree
ユーザー shotoyooshotoyoo
提出日時 2021-08-20 22:58:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 89,088 KB
最終ジャッジ日時 2024-04-22 06:44:10
合計ジャッジ時間 5,339 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
52,480 KB
testcase_02 AC 38 ms
52,992 KB
testcase_03 AC 42 ms
58,624 KB
testcase_04 AC 38 ms
52,992 KB
testcase_05 AC 38 ms
52,736 KB
testcase_06 AC 39 ms
52,992 KB
testcase_07 AC 38 ms
52,480 KB
testcase_08 AC 39 ms
52,352 KB
testcase_09 AC 39 ms
52,736 KB
testcase_10 AC 38 ms
52,224 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

def isqrt(n):
    """x*x<=nなる最大のx
    """
    x,y = n, (n+1)//2
    while y<x:
        x,y = y, (y + n//y) // 2
    return x

l,r = list(map(int, input().split()))
ok = [1]*(r-l+1)
# ok[i] : l+i
for i in range(2, 1010):
    ii = i*i
    ll = ((l+ii-1)//ii)*ii
    for k in range(ll, r+1, ii):
        ok[k-l] = 0
for i in range(1,r-l+1):
    ir = r//i
    k = isqrt(ir)
    kk = k*k
    if k>1 and l<=i*kk<=r:
        while i*kk-l>=0:
            ok[i*kk-l] = 0
            i -= 1
ans = sum(ok)
print(ans)
0