結果

問題 No.1653 Squarefree
ユーザー tamatotamato
提出日時 2021-08-21 16:38:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 689 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 84,736 KB
最終ジャッジ日時 2024-04-23 07:31:19
合計ジャッジ時間 17,527 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 141 ms
83,812 KB
testcase_02 AC 134 ms
83,868 KB
testcase_03 AC 146 ms
83,752 KB
testcase_04 AC 134 ms
84,120 KB
testcase_05 AC 133 ms
84,224 KB
testcase_06 AC 140 ms
84,348 KB
testcase_07 AC 139 ms
83,812 KB
testcase_08 AC 135 ms
83,884 KB
testcase_09 AC 136 ms
84,144 KB
testcase_10 AC 138 ms
84,068 KB
testcase_11 AC 138 ms
83,764 KB
testcase_12 AC 140 ms
84,064 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 132 ms
83,972 KB
testcase_37 WA -
testcase_38 AC 131 ms
84,116 KB
testcase_39 AC 140 ms
84,036 KB
testcase_40 AC 129 ms
84,236 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 = 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