結果

問題 No.1653 Squarefree
ユーザー ntudantuda
提出日時 2021-08-28 14:29:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,727 ms / 2,000 ms
コード長 1,110 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 259,092 KB
最終ジャッジ日時 2023-08-14 03:05:02
合計ジャッジ時間 47,717 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,721 ms
257,872 KB
testcase_01 AC 61 ms
71,648 KB
testcase_02 AC 62 ms
71,316 KB
testcase_03 AC 71 ms
76,780 KB
testcase_04 AC 62 ms
71,544 KB
testcase_05 AC 61 ms
71,720 KB
testcase_06 AC 61 ms
71,812 KB
testcase_07 AC 60 ms
71,848 KB
testcase_08 AC 64 ms
71,716 KB
testcase_09 AC 61 ms
71,996 KB
testcase_10 AC 60 ms
71,572 KB
testcase_11 AC 232 ms
84,684 KB
testcase_12 AC 233 ms
84,492 KB
testcase_13 AC 1,625 ms
258,040 KB
testcase_14 AC 1,586 ms
258,200 KB
testcase_15 AC 1,585 ms
258,064 KB
testcase_16 AC 1,621 ms
258,344 KB
testcase_17 AC 1,589 ms
257,976 KB
testcase_18 AC 1,582 ms
258,092 KB
testcase_19 AC 1,605 ms
257,936 KB
testcase_20 AC 1,558 ms
258,056 KB
testcase_21 AC 1,581 ms
257,940 KB
testcase_22 AC 1,580 ms
258,300 KB
testcase_23 AC 1,610 ms
257,916 KB
testcase_24 AC 1,563 ms
259,092 KB
testcase_25 AC 1,621 ms
258,016 KB
testcase_26 AC 1,610 ms
258,264 KB
testcase_27 AC 1,658 ms
257,732 KB
testcase_28 AC 1,609 ms
258,324 KB
testcase_29 AC 1,668 ms
258,020 KB
testcase_30 AC 1,727 ms
258,196 KB
testcase_31 AC 1,638 ms
258,044 KB
testcase_32 AC 1,697 ms
258,064 KB
testcase_33 AC 1,597 ms
258,140 KB
testcase_34 AC 1,624 ms
258,476 KB
testcase_35 AC 1,628 ms
258,288 KB
testcase_36 AC 814 ms
258,168 KB
testcase_37 AC 820 ms
257,912 KB
testcase_38 AC 801 ms
257,712 KB
testcase_39 AC 818 ms
257,948 KB
testcase_40 AC 844 ms
258,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math, sys
L,R = map(int,input().split())
if R == 1:
    print(1)
    sys.exit()
# 素数リスト作成
def seachPrimeNum(N):
    max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

PL = seachPrimeNum(math.ceil(pow(R,1/3)))
A = list(range(L,R+1))

for p in PL:
    p2 = p*p 
    for i in range(-(-L//p) * p - L, R//p * p - L + 1,p):
        j = 0
        while A[i] % p == 0:
            if j == 1:
                A[i] = -1
            else:
                A[i] //= p
            j += 1
def check(x,y):
    return x >= y*y
for i in range(R-L+1):
    a = A[i]
    if a > 1:
        lb = 0
        ub = R
        while ub - lb > 1:
            mid = (ub + lb) //2
            if check(a,mid):
                lb = mid
            else:
                ub = mid
        if a == lb * lb:
            A[i] = -1
ans = 0
for a in A:
    if a > 0:
        ans += 1
print(ans)
0