結果
| 問題 |
No.1653 Squarefree
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2021-08-27 22:37:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 895 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 82,204 KB |
| 実行使用メモリ | 288,432 KB |
| 最終ジャッジ日時 | 2024-11-21 03:41:38 |
| 合計ジャッジ時間 | 49,046 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | WA * 38 |
ソースコード
import math, copy,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)))
AL = set(range(L,R+1))
for p in PL:
p2 = p*p
for i in range(L//p2,R//p2+1):
if i*p2 in AL:
AL.remove(i*p2)
def check(x,y):
return x >= y*y
AL2 = copy.copy(AL)
for a in AL2:
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.remove(a)
print(AL)
print(len(AL))
ntuda