結果

問題 No.1653 Squarefree
ユーザー shotoyooshotoyoo
提出日時 2021-08-20 23:07:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,380 ms / 2,000 ms
コード長 871 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 83,968 KB
最終ジャッジ日時 2024-04-22 09:24:00
合計ジャッジ時間 40,640 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,345 ms
83,840 KB
testcase_01 AC 81 ms
59,392 KB
testcase_02 AC 84 ms
59,520 KB
testcase_03 AC 280 ms
75,648 KB
testcase_04 AC 81 ms
59,904 KB
testcase_05 AC 81 ms
60,032 KB
testcase_06 AC 81 ms
59,520 KB
testcase_07 AC 81 ms
59,904 KB
testcase_08 AC 82 ms
59,264 KB
testcase_09 AC 81 ms
59,776 KB
testcase_10 AC 81 ms
59,520 KB
testcase_11 AC 449 ms
83,840 KB
testcase_12 AC 456 ms
83,840 KB
testcase_13 AC 1,348 ms
83,328 KB
testcase_14 AC 1,345 ms
83,328 KB
testcase_15 AC 1,350 ms
83,456 KB
testcase_16 AC 1,350 ms
83,328 KB
testcase_17 AC 1,346 ms
83,712 KB
testcase_18 AC 1,349 ms
83,840 KB
testcase_19 AC 1,345 ms
83,328 KB
testcase_20 AC 1,380 ms
83,712 KB
testcase_21 AC 1,344 ms
83,456 KB
testcase_22 AC 1,341 ms
83,584 KB
testcase_23 AC 1,340 ms
83,456 KB
testcase_24 AC 1,339 ms
83,968 KB
testcase_25 AC 1,339 ms
83,584 KB
testcase_26 AC 1,337 ms
83,712 KB
testcase_27 AC 1,344 ms
83,840 KB
testcase_28 AC 1,332 ms
83,712 KB
testcase_29 AC 1,340 ms
83,840 KB
testcase_30 AC 1,338 ms
83,328 KB
testcase_31 AC 1,345 ms
83,328 KB
testcase_32 AC 1,344 ms
83,840 KB
testcase_33 AC 1,339 ms
83,456 KB
testcase_34 AC 1,345 ms
83,840 KB
testcase_35 AC 1,348 ms
83,968 KB
testcase_36 AC 621 ms
75,904 KB
testcase_37 AC 605 ms
75,520 KB
testcase_38 AC 604 ms
75,648 KB
testcase_39 AC 602 ms
75,520 KB
testcase_40 AC 600 ms
75,648 KB
権限があれば一括ダウンロードができます

ソースコード

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, 10**6+100):
    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,10**6+100):
    ir = r//i
    k = isqrt(ir)
    kk = k*k
    if kk<=10**6:
        continue
    if k>1 and l<=i*kk<=r:
        while i*kk-l>=0:
            ok[i*kk-l] = 0
            i -= 1
for v in range(max(2,l), r+1):
    vv = isqrt(v)
    if vv*vv==v:
        ok[v-l] = 0
ans = sum(ok)
print(ans)
0