結果

問題 No.1653 Squarefree
ユーザー rlangevinrlangevin
提出日時 2023-10-25 08:57:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 81,612 KB
実行使用メモリ 91,696 KB
最終ジャッジ日時 2023-10-25 08:57:35
合計ジャッジ時間 17,985 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 568 ms
91,484 KB
testcase_01 AC 80 ms
74,076 KB
testcase_02 AC 84 ms
74,076 KB
testcase_03 AC 86 ms
76,220 KB
testcase_04 AC 81 ms
74,076 KB
testcase_05 AC 81 ms
74,076 KB
testcase_06 AC 80 ms
74,076 KB
testcase_07 AC 82 ms
74,076 KB
testcase_08 AC 80 ms
74,076 KB
testcase_09 AC 86 ms
74,076 KB
testcase_10 AC 80 ms
74,076 KB
testcase_11 AC 278 ms
88,244 KB
testcase_12 AC 266 ms
88,244 KB
testcase_13 AC 507 ms
91,372 KB
testcase_14 AC 537 ms
91,608 KB
testcase_15 AC 565 ms
91,500 KB
testcase_16 AC 575 ms
91,448 KB
testcase_17 AC 513 ms
91,460 KB
testcase_18 AC 588 ms
91,696 KB
testcase_19 AC 546 ms
91,584 KB
testcase_20 AC 542 ms
91,696 KB
testcase_21 AC 560 ms
91,420 KB
testcase_22 AC 541 ms
91,696 KB
testcase_23 AC 555 ms
91,280 KB
testcase_24 AC 531 ms
91,448 KB
testcase_25 AC 524 ms
91,408 KB
testcase_26 AC 504 ms
91,624 KB
testcase_27 AC 530 ms
91,404 KB
testcase_28 AC 514 ms
91,356 KB
testcase_29 AC 571 ms
91,400 KB
testcase_30 AC 552 ms
91,616 KB
testcase_31 AC 537 ms
91,396 KB
testcase_32 AC 558 ms
91,612 KB
testcase_33 AC 530 ms
91,372 KB
testcase_34 AC 495 ms
91,408 KB
testcase_35 AC 562 ms
91,480 KB
testcase_36 AC 81 ms
74,076 KB
testcase_37 AC 80 ms
74,076 KB
testcase_38 AC 83 ms
74,076 KB
testcase_39 AC 85 ms
74,076 KB
testcase_40 AC 78 ms
74,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isqrt(n):
    yes = 1
    no = 10 ** 9 + 5
    while no - yes != 1:
        mid = (yes + no)//2
        if mid * mid <= n:
            yes = mid
        else:
            no = mid
    return yes * yes == n

L, R = map(int, input().split())
D = list(range(L, R + 1))
M = 10 ** 6 + 5
Prime = [1] * M
for i in range(2, M):
    if not Prime[i]:
        continue
    for j in range(2 * i, M, i):
        Prime[j] = 0
    start = (L + i - 1)//i * i
    for j in range(start - L, R - L + 1, i):
        if D[j] % (i * i) == 0:
            D[j] = 0
        elif D[j] % i == 0:
            D[j] //= i

ans = 0
for i in range(R - L + 1):
    if D[i] == 1:
        ans += 1
    elif D[i] == 0:
        continue    
    elif not isqrt(D[i]):
        ans += 1

print(ans)
0