結果

問題 No.1653 Squarefree
ユーザー ayaoniayaoni
提出日時 2021-08-20 22:03:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 974 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 86,340 KB
最終ジャッジ日時 2023-08-04 11:29:52
合計ジャッジ時間 27,920 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 911 ms
85,844 KB
testcase_01 AC 143 ms
77,020 KB
testcase_02 AC 143 ms
76,964 KB
testcase_03 AC 164 ms
78,148 KB
testcase_04 AC 142 ms
76,836 KB
testcase_05 AC 145 ms
76,952 KB
testcase_06 AC 144 ms
76,956 KB
testcase_07 AC 140 ms
76,972 KB
testcase_08 AC 138 ms
76,960 KB
testcase_09 AC 144 ms
76,952 KB
testcase_10 AC 142 ms
77,128 KB
testcase_11 AC 682 ms
85,580 KB
testcase_12 AC 651 ms
85,760 KB
testcase_13 AC 909 ms
86,112 KB
testcase_14 AC 961 ms
86,336 KB
testcase_15 AC 856 ms
86,128 KB
testcase_16 AC 881 ms
86,256 KB
testcase_17 AC 884 ms
86,004 KB
testcase_18 AC 974 ms
85,840 KB
testcase_19 AC 868 ms
85,960 KB
testcase_20 AC 949 ms
86,340 KB
testcase_21 AC 936 ms
86,288 KB
testcase_22 AC 937 ms
86,068 KB
testcase_23 AC 953 ms
85,864 KB
testcase_24 AC 905 ms
86,092 KB
testcase_25 AC 867 ms
86,268 KB
testcase_26 AC 872 ms
86,056 KB
testcase_27 AC 921 ms
86,280 KB
testcase_28 AC 935 ms
86,228 KB
testcase_29 AC 911 ms
86,152 KB
testcase_30 AC 909 ms
86,320 KB
testcase_31 AC 922 ms
86,180 KB
testcase_32 AC 837 ms
86,100 KB
testcase_33 AC 849 ms
86,116 KB
testcase_34 AC 904 ms
86,200 KB
testcase_35 AC 917 ms
86,136 KB
testcase_36 AC 145 ms
77,660 KB
testcase_37 AC 149 ms
77,112 KB
testcase_38 AC 140 ms
77,320 KB
testcase_39 AC 145 ms
77,208 KB
testcase_40 AC 143 ms
77,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


L,R = MI()

X = [i for i in range(L,R+1)]
for i in range(2,10**6+1):
    s = i**2
    for j in range(s*((L+s-1)//s)-L,s*(R//s+1)-L,s):
        X[j] = 0
    for j in range(i*((L+i-1)//i)-L,i*(R//i+1)-L,i):
        if X[j] % i == 0:
            X[j] //= i


def is_square(x):
    y = int(x**.5)
    for i in range(y-1,y+2):
        if i**2 == x:
            return True
    return False


ans = 0
for x in X:
    if x == 1:
        ans += 1
    elif x == 0:
        continue
    else:
        if not is_square(x):
            ans += 1

print(ans)
0