結果

問題 No.1653 Squarefree
ユーザー ayaoniayaoni
提出日時 2021-08-20 22:03:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,266 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 85,172 KB
最終ジャッジ日時 2024-04-22 09:06:45
合計ジャッジ時間 33,899 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,127 ms
84,940 KB
testcase_01 AC 107 ms
62,624 KB
testcase_02 AC 108 ms
63,104 KB
testcase_03 AC 132 ms
76,472 KB
testcase_04 AC 106 ms
61,696 KB
testcase_05 AC 107 ms
61,952 KB
testcase_06 AC 108 ms
61,952 KB
testcase_07 AC 107 ms
61,568 KB
testcase_08 AC 107 ms
62,168 KB
testcase_09 AC 107 ms
61,440 KB
testcase_10 AC 105 ms
61,824 KB
testcase_11 AC 880 ms
84,296 KB
testcase_12 AC 835 ms
84,216 KB
testcase_13 AC 1,139 ms
84,804 KB
testcase_14 AC 1,142 ms
84,716 KB
testcase_15 AC 1,191 ms
84,864 KB
testcase_16 AC 1,133 ms
85,052 KB
testcase_17 AC 1,147 ms
84,608 KB
testcase_18 AC 1,154 ms
84,600 KB
testcase_19 AC 1,165 ms
84,608 KB
testcase_20 AC 1,141 ms
84,788 KB
testcase_21 AC 1,225 ms
84,608 KB
testcase_22 AC 1,176 ms
85,172 KB
testcase_23 AC 1,214 ms
84,608 KB
testcase_24 AC 1,205 ms
84,736 KB
testcase_25 AC 1,266 ms
84,608 KB
testcase_26 AC 1,168 ms
84,724 KB
testcase_27 AC 1,250 ms
84,608 KB
testcase_28 AC 1,139 ms
84,612 KB
testcase_29 AC 1,205 ms
84,732 KB
testcase_30 AC 1,056 ms
84,612 KB
testcase_31 AC 1,195 ms
84,608 KB
testcase_32 AC 1,029 ms
84,588 KB
testcase_33 AC 1,167 ms
84,608 KB
testcase_34 AC 1,101 ms
84,820 KB
testcase_35 AC 1,218 ms
84,668 KB
testcase_36 AC 104 ms
62,504 KB
testcase_37 AC 105 ms
62,776 KB
testcase_38 AC 104 ms
61,988 KB
testcase_39 AC 104 ms
63,140 KB
testcase_40 AC 103 ms
62,568 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