結果

問題 No.1653 Squarefree
ユーザー rlangevinrlangevin
提出日時 2023-10-25 08:56:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,158 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 83,640 KB
最終ジャッジ日時 2023-10-25 08:56:40
合計ジャッジ時間 31,490 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,148 ms
83,544 KB
testcase_01 AC 59 ms
59,764 KB
testcase_02 AC 60 ms
59,764 KB
testcase_03 AC 89 ms
75,412 KB
testcase_04 AC 57 ms
59,764 KB
testcase_05 AC 59 ms
59,764 KB
testcase_06 AC 57 ms
59,764 KB
testcase_07 AC 58 ms
59,764 KB
testcase_08 AC 59 ms
59,764 KB
testcase_09 AC 58 ms
59,764 KB
testcase_10 AC 57 ms
59,764 KB
testcase_11 AC 661 ms
83,300 KB
testcase_12 AC 676 ms
83,300 KB
testcase_13 AC 1,059 ms
83,564 KB
testcase_14 AC 1,093 ms
83,588 KB
testcase_15 AC 1,158 ms
83,560 KB
testcase_16 AC 1,023 ms
83,516 KB
testcase_17 AC 1,069 ms
83,520 KB
testcase_18 AC 1,039 ms
83,640 KB
testcase_19 AC 1,096 ms
83,572 KB
testcase_20 AC 965 ms
83,636 KB
testcase_21 AC 1,095 ms
83,592 KB
testcase_22 AC 1,023 ms
83,636 KB
testcase_23 AC 939 ms
83,480 KB
testcase_24 AC 1,020 ms
83,516 KB
testcase_25 AC 1,026 ms
83,600 KB
testcase_26 AC 944 ms
83,592 KB
testcase_27 AC 978 ms
83,596 KB
testcase_28 AC 958 ms
83,552 KB
testcase_29 AC 1,049 ms
83,592 KB
testcase_30 AC 1,070 ms
83,580 KB
testcase_31 AC 942 ms
83,588 KB
testcase_32 AC 1,007 ms
83,576 KB
testcase_33 AC 1,060 ms
83,564 KB
testcase_34 AC 969 ms
83,596 KB
testcase_35 AC 1,063 ms
83,548 KB
testcase_36 AC 61 ms
59,764 KB
testcase_37 AC 59 ms
59,764 KB
testcase_38 AC 60 ms
59,764 KB
testcase_39 AC 59 ms
59,764 KB
testcase_40 AC 59 ms
59,764 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
for i in range(2, M):
    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