結果

問題 No.1653 Squarefree
ユーザー ntudantuda
提出日時 2021-08-28 14:22:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,118 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 259,272 KB
最終ジャッジ日時 2023-08-14 03:01:50
合計ジャッジ時間 55,032 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,937 ms
257,984 KB
testcase_01 AC 69 ms
71,556 KB
testcase_02 AC 70 ms
71,324 KB
testcase_03 AC 83 ms
76,912 KB
testcase_04 AC 71 ms
71,708 KB
testcase_05 AC 71 ms
71,892 KB
testcase_06 AC 72 ms
71,932 KB
testcase_07 AC 71 ms
72,048 KB
testcase_08 AC 73 ms
71,616 KB
testcase_09 AC 71 ms
71,832 KB
testcase_10 AC 72 ms
71,980 KB
testcase_11 AC 272 ms
84,644 KB
testcase_12 AC 275 ms
84,644 KB
testcase_13 AC 1,958 ms
258,220 KB
testcase_14 AC 1,884 ms
258,052 KB
testcase_15 AC 1,897 ms
258,288 KB
testcase_16 AC 1,937 ms
257,960 KB
testcase_17 AC 1,909 ms
257,972 KB
testcase_18 AC 1,879 ms
258,156 KB
testcase_19 AC 1,881 ms
258,060 KB
testcase_20 AC 1,875 ms
258,312 KB
testcase_21 AC 1,898 ms
258,176 KB
testcase_22 AC 1,878 ms
258,216 KB
testcase_23 AC 1,922 ms
258,188 KB
testcase_24 AC 1,866 ms
259,272 KB
testcase_25 AC 1,887 ms
257,852 KB
testcase_26 AC 1,866 ms
258,384 KB
testcase_27 AC 1,845 ms
258,200 KB
testcase_28 AC 1,841 ms
258,444 KB
testcase_29 AC 1,882 ms
258,056 KB
testcase_30 AC 1,856 ms
258,248 KB
testcase_31 AC 1,889 ms
258,328 KB
testcase_32 AC 1,942 ms
258,188 KB
testcase_33 AC 1,884 ms
258,244 KB
testcase_34 AC 1,919 ms
258,080 KB
testcase_35 AC 1,922 ms
258,208 KB
testcase_36 AC 908 ms
257,984 KB
testcase_37 WA -
testcase_38 AC 896 ms
258,060 KB
testcase_39 AC 893 ms
257,660 KB
testcase_40 AC 894 ms
257,992 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):
    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
#print(A)
ans = 0
for a in A:
    if a > 0:
        ans += 1
print(ans)
0