結果

問題 No.1653 Squarefree
ユーザー tamatotamato
提出日時 2021-08-21 16:35:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 806 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 412,816 KB
最終ジャッジ日時 2024-04-23 07:27:57
合計ジャッジ時間 6,715 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


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

    L, R = map(int, input().split())
    N = 10 ** 6
    div = [[] for _ in range(N+1)]
    for d in range(2, N+1):
        for x in range(2, N+1):
            if d*x > N:
                break
            div[d*x].append(d)
    cnt = [0] * (N + 1)
    for d in range(N, 1, -1):
        cnt[d] += R // (d**2) - (L - 1) // (d**2)
        for e in div[d]:
            cnt[e] -= cnt[d]
    ans = R - (L - 1) - sum(cnt)
    for i in range(L, R+1):
        if i <= N**2:
            continue
        j = sqrt(i)
        for k in range(-2, 3):
            if j+k > 0:
                if (j+k) ** 2 == i:
                    ans -= 1
    print(ans)


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