結果

問題 No.1653 Squarefree
ユーザー hir355hir355
提出日時 2021-08-20 23:20:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 738 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 118,136 KB
最終ジャッジ日時 2024-04-22 07:47:37
合計ジャッジ時間 8,839 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 121 ms
87,872 KB
testcase_02 AC 126 ms
87,008 KB
testcase_03 AC 129 ms
91,044 KB
testcase_04 AC 123 ms
87,932 KB
testcase_05 AC 121 ms
88,152 KB
testcase_06 AC 125 ms
87,820 KB
testcase_07 AC 122 ms
87,336 KB
testcase_08 AC 122 ms
87,708 KB
testcase_09 AC 122 ms
88,244 KB
testcase_10 AC 119 ms
87,496 KB
testcase_11 AC 180 ms
106,528 KB
testcase_12 AC 181 ms
107,468 KB
testcase_13 AC 201 ms
117,896 KB
testcase_14 AC 204 ms
117,696 KB
testcase_15 AC 202 ms
117,816 KB
testcase_16 AC 202 ms
117,812 KB
testcase_17 AC 201 ms
117,864 KB
testcase_18 AC 209 ms
117,852 KB
testcase_19 AC 201 ms
117,804 KB
testcase_20 AC 204 ms
117,796 KB
testcase_21 AC 200 ms
117,980 KB
testcase_22 AC 206 ms
118,016 KB
testcase_23 AC 202 ms
117,872 KB
testcase_24 WA -
testcase_25 AC 202 ms
117,808 KB
testcase_26 AC 204 ms
117,772 KB
testcase_27 AC 200 ms
117,996 KB
testcase_28 AC 200 ms
117,700 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 203 ms
117,904 KB
testcase_32 AC 201 ms
117,964 KB
testcase_33 AC 201 ms
117,796 KB
testcase_34 AC 200 ms
117,996 KB
testcase_35 AC 202 ms
117,940 KB
testcase_36 AC 139 ms
101,916 KB
testcase_37 WA -
testcase_38 AC 138 ms
101,924 KB
testcase_39 AC 140 ms
102,060 KB
testcase_40 AC 141 ms
101,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

l, r = map(int, input().split())
k = list(range(l, r + 1))
d = [1] * (r - l + 1)
pr = primes(2000000)
for p in pr:
    x = 1
    while x * p * p <= r:
        x *= p * p
        for i in range(l + x - 1 - (l + x - 1) % x, r + 1, x):
            k[i - l] //= p * p
            d[i - l] = 0
ans = r - l + 1
for i in range(r - l + 1):
    if d[i] == 0 or int((k[i]+1)**.5)==k[i]:
        ans -= 1
if l == 1:
    ans += 1
print(ans)
0