結果

問題 No.1653 Squarefree
ユーザー chocoruskchocorusk
提出日時 2021-07-31 02:49:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 389 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 82,668 KB
実行使用メモリ 100,468 KB
最終ジャッジ日時 2024-04-22 09:04:05
合計ジャッジ時間 12,959 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 389 ms
100,108 KB
testcase_01 AC 95 ms
74,144 KB
testcase_02 AC 99 ms
74,648 KB
testcase_03 AC 100 ms
75,708 KB
testcase_04 AC 96 ms
74,952 KB
testcase_05 AC 94 ms
74,776 KB
testcase_06 AC 98 ms
74,492 KB
testcase_07 AC 98 ms
74,388 KB
testcase_08 AC 96 ms
75,508 KB
testcase_09 AC 98 ms
74,428 KB
testcase_10 AC 94 ms
74,184 KB
testcase_11 AC 305 ms
97,820 KB
testcase_12 AC 309 ms
97,152 KB
testcase_13 AC 376 ms
100,120 KB
testcase_14 AC 379 ms
99,936 KB
testcase_15 AC 368 ms
100,196 KB
testcase_16 AC 372 ms
100,044 KB
testcase_17 AC 379 ms
100,104 KB
testcase_18 AC 379 ms
100,240 KB
testcase_19 AC 374 ms
100,016 KB
testcase_20 AC 380 ms
99,892 KB
testcase_21 AC 374 ms
100,468 KB
testcase_22 AC 378 ms
99,976 KB
testcase_23 AC 384 ms
99,780 KB
testcase_24 AC 368 ms
100,196 KB
testcase_25 AC 356 ms
100,260 KB
testcase_26 AC 363 ms
100,260 KB
testcase_27 AC 367 ms
100,280 KB
testcase_28 AC 362 ms
100,252 KB
testcase_29 AC 367 ms
99,928 KB
testcase_30 AC 377 ms
100,236 KB
testcase_31 AC 373 ms
99,972 KB
testcase_32 AC 375 ms
100,272 KB
testcase_33 AC 355 ms
100,024 KB
testcase_34 AC 364 ms
100,124 KB
testcase_35 AC 363 ms
100,236 KB
testcase_36 AC 98 ms
74,940 KB
testcase_37 AC 94 ms
74,196 KB
testcase_38 AC 92 ms
74,408 KB
testcase_39 AC 97 ms
75,156 KB
testcase_40 AC 95 ms
74,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
import math
def prime_sieve(n):
    isprime=[True]*(n+1)
    isprime[0]=False
    isprime[1]=False
    for i in range(2, n+1):
        if isprime[i]:
            for j in range(2*i, n+1, i):
                isprime[j]=False
    return isprime
isprime=prime_sieve(1000000)
l, r=map(int, readline().split())
v=list(range(l, r+1))
sqf=[True]*(r-l+1)
for p in range(2, 1000000):
    if not isprime[p]:
        continue
    for i in range((l+p-1)//p*p, r+1, p):
        if not sqf[i-l]:
            continue
        v[i-l]//=p
        if v[i-l]%p==0:
            sqf[i-l]=False
ans=0
for i in range(r-l+1):
    if not sqf[i]:
        continue
    if v[i]==1:
        ans+=1
        continue
    sq=int(math.sqrt(v[i]))
    ans+=1
    for j in range(sq, sq+2):
        if j*j==v[i]:
            ans-=1
            break
print(ans)
0