結果

問題 No.1653 Squarefree
ユーザー ntudantuda
提出日時 2021-08-28 14:27:54
言語 PyPy3
(7.3.15)
結果
OLE  
実行時間 -
コード長 1,145 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 257,876 KB
最終ジャッジ日時 2023-08-14 03:03:53
合計ジャッジ時間 59,170 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 OLE -
testcase_01 WA -
testcase_02 AC 60 ms
71,268 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 OLE -
testcase_14 OLE -
testcase_15 OLE -
testcase_16 OLE -
testcase_17 OLE -
testcase_18 OLE -
testcase_19 OLE -
testcase_20 OLE -
testcase_21 OLE -
testcase_22 OLE -
testcase_23 OLE -
testcase_24 OLE -
testcase_25 OLE -
testcase_26 OLE -
testcase_27 OLE -
testcase_28 OLE -
testcase_29 OLE -
testcase_30 OLE -
testcase_31 OLE -
testcase_32 OLE -
testcase_33 OLE -
testcase_34 OLE -
testcase_35 OLE -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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
print(A)
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
        print(lb)
        if a == lb * lb:
            A[i] = -1
print(A)
ans = 0
for a in A:
    if a > 0:
        ans += 1
print(ans)
0