結果

問題 No.1653 Squarefree
ユーザー kozy
提出日時 2021-08-20 23:02:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 141,180 KB
最終ジャッジ日時 2024-10-14 08:33:48
合計ジャッジ時間 8,872 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

S=set()
L,R=map(int,input().split())
M=10**6
for i in range(2,M+1):
  s=i**2
  l=s+(s*((L-1)//s))
  for j in range(l,R+1,s):
    S.add(j)
for a in range(1,M+1):
  l,r=((L-1)//a)+1,R//a
  if l>r:
    continue
  #l~rにある平方数
  s=int(l**0.5)-2
  while True:
    if s<=1:
      s=2
    if l<=s**2<=r:
      S.add((s**2)*a)
      s+=1
    elif s**2<l:
      s+=1
    else:
      break
print(R-L+1-len(S))
0