結果

問題 No.1653 Squarefree
ユーザー tamatotamato
提出日時 2021-08-21 16:42:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 84,660 KB
最終ジャッジ日時 2024-04-23 07:33:58
合計ジャッジ時間 9,702 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 160 ms
84,060 KB
testcase_02 AC 174 ms
84,132 KB
testcase_03 AC 170 ms
84,012 KB
testcase_04 AC 160 ms
84,136 KB
testcase_05 AC 173 ms
83,864 KB
testcase_06 AC 151 ms
83,928 KB
testcase_07 AC 170 ms
83,960 KB
testcase_08 AC 170 ms
84,024 KB
testcase_09 AC 167 ms
83,872 KB
testcase_10 AC 159 ms
84,412 KB
testcase_11 AC 177 ms
84,604 KB
testcase_12 AC 175 ms
83,924 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 225 ms
84,108 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 216 ms
83,932 KB
testcase_20 AC 215 ms
84,064 KB
testcase_21 AC 225 ms
83,940 KB
testcase_22 WA -
testcase_23 AC 222 ms
83,984 KB
testcase_24 WA -
testcase_25 AC 220 ms
84,088 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 229 ms
84,088 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 224 ms
84,172 KB
testcase_33 AC 231 ms
84,400 KB
testcase_34 AC 219 ms
84,304 KB
testcase_35 AC 224 ms
84,300 KB
testcase_36 AC 166 ms
83,860 KB
testcase_37 AC 157 ms
84,224 KB
testcase_38 AC 153 ms
83,820 KB
testcase_39 AC 168 ms
83,960 KB
testcase_40 AC 163 ms
83,812 KB
権限があれば一括ダウンロードができます

ソースコード

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
    cnt = [0] * (N + 1)
    for d in range(N, 1, -1):
        cnt[d] += R // (d**2) - (L - 1) // (d**2)
        for x in range(2, N+1):
            if d*x > N:
                break
            cnt[d] -= cnt[d*x]
    ans = R - (L - 1) - sum(cnt)
    for i in range(L, R+1):
        if i <= N**2:
            continue
        j = int(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