結果

問題 No.1653 Squarefree
ユーザー shotoyooshotoyoo
提出日時 2021-08-20 22:59:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 83,968 KB
最終ジャッジ日時 2024-04-22 06:55:34
合計ジャッジ時間 16,189 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
52,736 KB
testcase_02 AC 37 ms
52,608 KB
testcase_03 AC 43 ms
58,624 KB
testcase_04 AC 39 ms
52,736 KB
testcase_05 AC 39 ms
52,096 KB
testcase_06 AC 37 ms
52,096 KB
testcase_07 AC 39 ms
52,480 KB
testcase_08 AC 38 ms
52,224 KB
testcase_09 AC 39 ms
52,608 KB
testcase_10 AC 39 ms
52,480 KB
testcase_11 AC 130 ms
83,556 KB
testcase_12 AC 131 ms
83,584 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 37 ms
52,224 KB
testcase_37 WA -
testcase_38 AC 38 ms
52,864 KB
testcase_39 AC 37 ms
52,224 KB
testcase_40 AC 37 ms
52,736 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, 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 kk<=10**6:
        continue
    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