結果

問題 No.1653 Squarefree
ユーザー mkawa2mkawa2
提出日時 2023-02-19 15:35:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,260 ms / 2,000 ms
コード長 1,357 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 250,864 KB
最終ジャッジ日時 2023-09-27 21:18:59
合計ジャッジ時間 36,572 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,099 ms
191,884 KB
testcase_01 AC 221 ms
242,340 KB
testcase_02 AC 214 ms
241,376 KB
testcase_03 AC 263 ms
242,476 KB
testcase_04 AC 216 ms
241,496 KB
testcase_05 AC 217 ms
241,288 KB
testcase_06 AC 222 ms
241,624 KB
testcase_07 AC 218 ms
241,384 KB
testcase_08 AC 210 ms
242,540 KB
testcase_09 AC 216 ms
241,696 KB
testcase_10 AC 216 ms
241,416 KB
testcase_11 AC 614 ms
250,864 KB
testcase_12 AC 620 ms
250,716 KB
testcase_13 AC 1,074 ms
191,572 KB
testcase_14 AC 1,017 ms
191,732 KB
testcase_15 AC 1,050 ms
191,876 KB
testcase_16 AC 1,031 ms
191,764 KB
testcase_17 AC 1,042 ms
191,708 KB
testcase_18 AC 1,042 ms
191,708 KB
testcase_19 AC 1,069 ms
191,592 KB
testcase_20 AC 1,080 ms
194,856 KB
testcase_21 AC 1,205 ms
191,784 KB
testcase_22 AC 1,105 ms
191,620 KB
testcase_23 AC 1,074 ms
194,784 KB
testcase_24 AC 1,080 ms
191,736 KB
testcase_25 AC 1,088 ms
191,896 KB
testcase_26 AC 1,082 ms
191,592 KB
testcase_27 AC 1,077 ms
191,628 KB
testcase_28 AC 1,260 ms
195,120 KB
testcase_29 AC 1,222 ms
191,804 KB
testcase_30 AC 1,085 ms
192,168 KB
testcase_31 AC 1,065 ms
191,684 KB
testcase_32 AC 1,085 ms
191,916 KB
testcase_33 AC 1,027 ms
191,740 KB
testcase_34 AC 1,103 ms
191,876 KB
testcase_35 AC 1,238 ms
191,732 KB
testcase_36 AC 269 ms
242,468 KB
testcase_37 AC 270 ms
242,804 KB
testcase_38 AC 265 ms
242,528 KB
testcase_39 AC 274 ms
242,740 KB
testcase_40 AC 263 ms
242,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

def floor_sqrt(x):
    a = round(x**0.5-0.49)
    while a**2 > x: a -= 1
    return a

def issquare(a):
    if a == 1: return False
    if a <= 1000000000000: return a in a2
    r = floor_sqrt(a)
    return r**2 == a

mx = 1000001

l, r = LI()
r += 1
# a^2*b
dp = [0]*(r-l)

a2 = set()
for a in range(2, mx):
    a = a*a
    a2.add(a)
    if a >= r: continue
    s = (l+a-1)//a*a
    for i in range(s, r, a):
        dp[i-l] = 1
# pDB(dp)

for a in range(1, mx):
    if a >= r: break
    s = (l+a-1)//a*a
    for i in range(s, r, a):
        if dp[i-l]: continue
        if issquare(i//a): dp[i-l] = 1
# pDB(dp)

print(r-l-sum(dp))
0