結果

問題 No.1653 Squarefree
ユーザー tamatotamato
提出日時 2021-08-21 17:33:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 541 ms / 2,000 ms
コード長 1,255 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 84,852 KB
最終ジャッジ日時 2024-04-23 08:21:20
合計ジャッジ時間 15,623 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 475 ms
84,356 KB
testcase_01 AC 64 ms
59,392 KB
testcase_02 AC 69 ms
58,880 KB
testcase_03 AC 101 ms
76,440 KB
testcase_04 AC 65 ms
59,008 KB
testcase_05 AC 63 ms
59,136 KB
testcase_06 AC 63 ms
58,900 KB
testcase_07 AC 64 ms
58,752 KB
testcase_08 AC 67 ms
59,008 KB
testcase_09 AC 66 ms
59,392 KB
testcase_10 AC 65 ms
58,752 KB
testcase_11 AC 413 ms
84,044 KB
testcase_12 AC 390 ms
84,264 KB
testcase_13 AC 507 ms
84,820 KB
testcase_14 AC 472 ms
84,460 KB
testcase_15 AC 515 ms
84,532 KB
testcase_16 AC 477 ms
84,852 KB
testcase_17 AC 498 ms
84,224 KB
testcase_18 AC 480 ms
84,600 KB
testcase_19 AC 504 ms
84,608 KB
testcase_20 AC 457 ms
84,344 KB
testcase_21 AC 509 ms
84,544 KB
testcase_22 AC 454 ms
84,448 KB
testcase_23 AC 507 ms
84,272 KB
testcase_24 AC 463 ms
84,788 KB
testcase_25 AC 541 ms
84,644 KB
testcase_26 AC 452 ms
84,232 KB
testcase_27 AC 505 ms
84,220 KB
testcase_28 AC 465 ms
84,556 KB
testcase_29 AC 501 ms
84,224 KB
testcase_30 AC 489 ms
84,456 KB
testcase_31 AC 513 ms
84,216 KB
testcase_32 AC 503 ms
84,568 KB
testcase_33 AC 524 ms
84,736 KB
testcase_34 AC 482 ms
84,700 KB
testcase_35 AC 499 ms
84,588 KB
testcase_36 AC 65 ms
59,148 KB
testcase_37 AC 69 ms
60,244 KB
testcase_38 AC 71 ms
59,476 KB
testcase_39 AC 70 ms
59,996 KB
testcase_40 AC 64 ms
60,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import sqrt
    input = sys.stdin.readline

    N = 10 ** 6
    L, R = map(int, input().split())
    A = list(range(L, R+1))
    for d in range(2, N+1):
        xl = (L - 1) // d + 1
        xr = R // d
        for x in range(xl, xr + 1):
            m = A[d * x - L]
            if m != -1:
                if m % (d**2) == 0:
                    A[d*x - L] = -1
                else:
                    if m % d == 0:
                        A[d * x - L] //= d
    ans = 0
    for m_ in range(L, R+1):
        if A[m_ - L] == -1:
            continue
        ans += 1
        m = A[m_ - L]
        if m != 1:
            mm = int(sqrt(m))
            for j in range(-2, 3):
                if mm + j > 0:
                    if (mm + j) ** 2 == m:
                        if mm + j > N:
                            ans -= 1
    print(ans)

    """
    # guchoku
    cnt = 0
    ok = [0] * (R - L + 1)
    for i in range(L, R+1):
        flg = 1
        for d in range(2, 101):
            if i % (d**2) == 0:
                flg = 0
                break
        cnt += flg
        if flg:
            ok[i - L] = 1
    print(cnt)
    """


if __name__ == '__main__':
    main()
0