結果

問題 No.1653 Squarefree
ユーザー ntudantuda
提出日時 2021-08-28 14:15:51
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 1,118 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 266,464 KB
最終ジャッジ日時 2023-08-14 02:59:40
合計ジャッジ時間 7,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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 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):
        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):
    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:
            AL[i] = -1
#print(A)
ans = 0
for a in A:
    if a > 0:
        ans += 1
print(ans)
0