結果

問題 No.1653 Squarefree
ユーザー titiatitia
提出日時 2021-08-21 04:11:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 877 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 246,752 KB
最終ジャッジ日時 2024-04-22 13:23:19
合計ジャッジ時間 32,600 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 877 ms
246,016 KB
testcase_01 AC 514 ms
187,808 KB
testcase_02 AC 529 ms
188,264 KB
testcase_03 AC 549 ms
200,872 KB
testcase_04 AC 523 ms
187,548 KB
testcase_05 AC 537 ms
187,856 KB
testcase_06 AC 525 ms
187,568 KB
testcase_07 AC 539 ms
187,836 KB
testcase_08 AC 542 ms
187,812 KB
testcase_09 AC 530 ms
187,864 KB
testcase_10 AC 537 ms
188,112 KB
testcase_11 AC 801 ms
246,300 KB
testcase_12 AC 813 ms
246,592 KB
testcase_13 AC 852 ms
246,316 KB
testcase_14 AC 862 ms
246,024 KB
testcase_15 AC 855 ms
246,188 KB
testcase_16 AC 858 ms
246,424 KB
testcase_17 AC 855 ms
246,040 KB
testcase_18 AC 865 ms
246,316 KB
testcase_19 AC 848 ms
246,160 KB
testcase_20 AC 864 ms
246,440 KB
testcase_21 AC 854 ms
246,500 KB
testcase_22 AC 852 ms
246,528 KB
testcase_23 AC 852 ms
246,292 KB
testcase_24 AC 869 ms
246,316 KB
testcase_25 AC 855 ms
246,624 KB
testcase_26 AC 863 ms
246,432 KB
testcase_27 AC 858 ms
246,312 KB
testcase_28 AC 851 ms
246,216 KB
testcase_29 AC 853 ms
246,192 KB
testcase_30 AC 864 ms
246,008 KB
testcase_31 AC 865 ms
246,440 KB
testcase_32 AC 860 ms
246,600 KB
testcase_33 AC 849 ms
246,140 KB
testcase_34 AC 849 ms
246,288 KB
testcase_35 AC 851 ms
246,752 KB
testcase_36 AC 523 ms
187,816 KB
testcase_37 AC 524 ms
188,176 KB
testcase_38 AC 527 ms
187,692 KB
testcase_39 AC 529 ms
188,136 KB
testcase_40 AC 529 ms
187,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L0,R0=map(int,input().split())

if L0==1:
    ANS=1
    L0+=1
else:
    ANS=0
A=[]

for i in range(L0,R0+1):
    A.append(i)

import math

x=10**7+100

L=math.floor(math.sqrt(x)) # 平方根を求める

Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]

for p in Primes:
    for i in range((L0+p-1)//p*p,(R0+p)//p*p,p):
        x=i-L0

        if A[x]%(p*p)==0:
            A[x]=0

        if A[x]%p==0:
            A[x]//=p

for a in A:
    if a==0:
        continue
    sq=int(math.sqrt(a))
    if a==1 or sq*sq!=a:
        ANS+=1

print(ANS)
            
        



0