結果
問題 | No.1653 Squarefree |
ユーザー |
![]() |
提出日時 | 2021-08-28 14:27:54 |
言語 | PyPy3 (7.3.15) |
結果 |
OLE
|
実行時間 | - |
コード長 | 1,145 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 81,992 KB |
実行使用メモリ | 254,944 KB |
最終ジャッジ日時 | 2024-11-21 21:02:30 |
合計ジャッジ時間 | 58,936 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | WA * 14 OLE * 24 |
ソースコード
import math, sysL,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 primeNumPL = seachPrimeNum(math.ceil(pow(R,1/3)))A = list(range(L,R+1))for p in PL:p2 = p*pfor i in range(-(-L//p) * p - L, R//p * p - L + 1,p):j = 0while A[i] % p == 0:if j == 1:A[i] = -1else:A[i] //= pj += 1def check(x,y):return x >= y*yprint(A)for i in range(R-L+1):a = A[i]if a > 1:lb = 0ub = Rwhile ub - lb > 1:mid = (ub + lb) //2if check(a,mid):lb = midelse:ub = midprint(lb)if a == lb * lb:A[i] = -1print(A)ans = 0for a in A:if a > 0:ans += 1print(ans)